I have an Album model and Track model. They have OneToMany relationship. An Album can have many tracks and a track can only belong to one Album. I'm using media library to associate the files of a song which is the cover and the mp3 to a Track model.
In my AlbumController, I have a query like this;
$album = $album->where('id', $id)->with('tracks', 'artist')->first();
return view('admins.albums.show', compact('album'));
This loads the tracks of the album but not the media. In my views, I can get the media by looping through the tracks and calling the getMedia() function but what about for Api?
How can I return the media as a Json before it is sent as a response?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire