belongsTo(Resource::class, 'cover', 'id')->select(['path', 'id', 'url']); } public function coordinator() { return $this->belongsTo(User::class)->select(['id', 'name', 'mobile', 'headimg', 'turename', 'userrate', 'personal_signature']); } public function user() { return $this->belongsTo(User::class)->select(['id', 'name', 'mobile', 'turename']); } public function courses() { return $this->belongsToMany(Course::class, 'course_organization_course')->withTimestamps(); } public function students() { return $this->belongsToMany(User::class, 'course_organization_student')->withTimestamps(); } public function setTagsAttribute($val) { $this->attributes['tags'] = '-' . arr2str($val, '-') . '-'; } public function getTagsAttribute($val) { return str2arr(trim($val, '-'), '-'); } public function student() { return $this->hasMany(OrganizationStudent::class); } public function getIsMemberStatusAttribute() { return OrganizationStudent::query()->where('organization_id', $this->attributes['id'])->where('user_id', login_user_id())->where('status', ModelStatusEnum::OK)->exists(); } }