belongsToMany(User::class, 'user_song')->withTimestamps(); } public function str_artists_plus(): string { return ($this->artistB!=null) ? $this->artistA ." + ".$this->artistB :$this->artistA; } public function artists(){ return $this->belongsToMany(Artist::class); } public function str_categories(){ return $this->categories->pluck('name')->implode(', '); } public function categories(){ return $this->belongsToMany(SongCategory::class); } }