芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Models/ProjectTemplate.php
belongsTo(ProjectCategory::class); } public function client(): BelongsTo { return $this->belongsTo(User::class)->withoutGlobalScope(ActiveScope::class); } public function members(): HasMany { return $this->hasMany(ProjectTemplateMember::class); } public function tasks(): HasMany { return $this->hasMany(ProjectTemplateTask::class, 'project_template_id')->orderBy('id', 'desc'); } /** * @return bool */ public function checkProjectUser() { $project = ProjectTemplateMember::where('project_template_id', $this->id) ->where('user_id', user()->id) ->count(); if ($project > 0) { return true; } else { return false; } } /** * @return bool */ public function checkProjectClient() { $project = ProjectTemplateMember::where('id', $this->id) ->where('client_id', user()->id) ->count(); if ($project > 0) { return true; } else { return false; } } public static function clientProjects($clientId) { return ProjectTemplateMember::where('client_id', $clientId)->get(); } public static function byEmployee($employeeId) { return ProjectTemplateMember::join('project_template_members', 'project_template_members.project_template_id', '=', 'project_templates.id') ->where('project_template_members.user_id', $employeeId) ->get(); } public function projectMembers(): BelongsToMany { return $this->belongsToMany(User::class, 'project_template_members'); } }