I want to get the path of an image using mutators or helper function for example this is My request :
"placeType": {
"id": 1,
"name": "Kenya Wyman",
"image_name": "1574668070.png",
"status": 1,
}
}
I want it to appear like this :
"placeType": {
"id": 1,
"name": "Kenya Wyman",
"image_name": "www.mydomain.com/photos/1574668070.png",
"status": 1,
}
}
Try This
$user->image_name = url('public/Your path ' . $user->image_name);
OR
In your Model Add this
public function getImageNameAttribute($value)
{
return public_path($value);
}
尝试使用此代码:
$data->image_name = URL::to('/') . '/public/imageFolder/' . $placeType->image_name;
Try to use this code :
asset('photos/1574668070.png');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.