belongsTo(User::class)->select(['name', 'headimg']); } public function setTagsAttribute($val) { if (count($val) == 0) return ''; $this->attributes['tags'] = '-' . arr2str($val, '-') . '-'; } public function getTagsAttribute($val) { return str2arr(trim($val, '-'), '-'); } public function category() { return $this->belongsTo(Category::class, 'course_category_id', 'id')->select(['name']); } }