I have a media table in relation to the user. when I save a media for the user, normally only URL like storage/folder/filename is store in the DB. How to add the base url to this on the fly when the API is been called?
In short, what I need to do is a prefix that column with the domain name in API only.
@sti3bas that gives me the URL which I have already mentioned.
result is storage/folder/filename and not domain/storage/folder/filename, which is what I want. Also I need it to be only provided in the API result and don't want to save the data in that way in database.
@sti3bas this does gives me full URL but one problem in this. for some reason, the URL is like domain/media-folder/media-file and is not accessible. but if I add storage beforemedia-folder like domain/storage/media-folder/media-file I am able to access the file.
that is what I came up with this, before after your answer. Now only one issue left ! how to override the data of the URL column with this URL output in the model itself.
currently Implemented the $append method but it gives an extra row in API. What shall I do for this ?
@sti3bas the above answer worked for me perfectly. Thank you for your assistance :D
One last request / help I need now.
as I told that the media file is in relation to user. now not every user have media file uploaded. so how to only get the records of user where they have media file record with them.