no message

This commit is contained in:
kuaifan
2021-06-04 23:32:44 +08:00
parent f3d4d3199f
commit 7405c5bba8
18 changed files with 863 additions and 235 deletions
+27
View File
@@ -2,6 +2,8 @@
namespace App\Models;
use App\Module\Base;
/**
* Class ProjectUser
*
@@ -12,6 +14,7 @@ namespace App\Models;
* @property int|null $owner 是否负责人
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Project|null $project
* @method static \Illuminate\Database\Eloquent\Builder|ProjectUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ProjectUser newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ProjectUser query()
@@ -26,4 +29,28 @@ namespace App\Models;
class ProjectUser extends AbstractModel
{
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function project(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Project::class, 'id', 'project_id');
}
/**
* 退出项目
* @return bool
*/
public function exitProject() {
$result = AbstractModel::transaction(function () {
WebSocketDialogUser::whereDialogId($this->project->dialog_id)->whereUserid($this->userid)->delete();
if ($this->delete()) {
return Base::retSuccess('success');
} else {
return Base::retError('error');
}
});
return Base::isSuccess($result);
}
}