Reputation: 730
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,
}
}
Upvotes: 3
Views: 4502
Reputation: 6005
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);
}
Upvotes: 3
Reputation:
Try to use this code :
$data->image_name = URL::to('/') . '/public/imageFolder/' . $placeType->image_name;
Upvotes: 0