'boolean', 'order' => 'integer', ]; protected $appends = [ 'comments_count', 'has_user_commented', 'user_comment', 'user_comment_id', 'is_liked', 'likes_count', 'is_saved', 'saved_count' ]; public function category(): BelongsTo { return $this->belongsTo(MusicCategory::class, 'category_id'); } public function subcategory(): BelongsTo { return $this->belongsTo(MusicSubcategory::class, 'subcategory_id'); } public function musics(): HasMany { return $this->hasMany(Music::class, 'playlist_id'); } public function image(): BelongsTo { return $this->belongsTo(Image::class); } public function getActiveMusicsAttribute() { return $this->musics()->where('is_active', true)->orderBy('order')->get(); } public function getTotalDurationAttribute() { return $this->musics()->where('is_active', true)->sum('duration'); } }