Working with a database that has a table and fields such as
album
id
titleId
titleName
track
id
titleId
trackId
trackName
artist
id
artistId
track_log
id
artistId
titleId
in this case mutiple artists can own a track, and there can be multiple tracks on an album.
Using a model I am able to return all tracks for an album like so
public function track() {
return $this->belongsTo('App\Album', 'titleId', 'titleId');
}
So I am now able to use $album->track to pull all tracks on that album.
It would return
{
"id": 1,
"titleId": 3,
"titleName": "Why so hard?",
},
I am looking for a way to highlight the tracks on the album that artist worked on by appending the artistId on to the results for the track in the model? Something along the lines as
trackHighlightArtist()
So that that would return something such as:
{
"id": 1,
"titleId": 3,
"titleName": "Why so hard?",
"artistId": 4,
},
Is this possible?