Reputation: 168
In my laravel app database, the resource are saved as link like this
/storages/photos/bla-bla.png
what is the best way, so I can append my app url to the result,
www.baseurl.example/storages/photos/bla-bla.png
it's because the backend and front end has difference base url Thanks
Upvotes: 0
Views: 651
Reputation: 12845
IT can be achieved in two ways
$request->photo
->storeAs(
'photos',
config('app.url'). $request->file('photo')->getClientOriginalName()
);
class Some extends Model
{
public function getPhotoAttribute($value)
{
return config('app.url'). $value;
}
public function setPhotoAttribute($value)
{
$this->attributes['photo'] = str_replace(config('app.url'), '', $value);
}
}
You need to set the correct value for APP_URL in the .env file
Upvotes: 1