'json', 'labels' => 'json', ]; public function category() { return $this->belongsTo(Category::class, 'category_id', 'id')->select(['name', 'id']); } public function thumb_resource() { return $this->belongsTo(Resource::class, 'thumb', 'id')->select(['path', 'id', 'url']); } public function attaches() { return $this->hasMany(Attach::class, 'course_id', 'id'); } public function subscribe() { return $this->hasOne(Subscribe::class)->select(['id', 'is_watched', 'progress', 'watched_at', 'created_at']); } public function comments() { return $this->hasMany(Comment::class); } public function getVideoNumsAttribute() { return Video::query()->where('course_id', $this->attributes['id'])->where('status', ModelStatusEnum::OK)->count(); } }