I am using this way to get the image url but it will not working. please anyone can give me the answer
<img src="{{ $user->getImageUrl() }}" alt="profile picture">
i am storing the image path in the database like this profile/xa6OUndH8AoSZ6bL1JbQe1CXM5tedXfoRbMDVgCQ.png
my funciton on User model
function getImageUrl(){
if($this->image){
$imagePath = 'public/' . $this->image;
if(Storage::exists($imagePath)){
return url('storage/' . $this->image);
}
}
return url('storage/default-user.png');
}
Here is the location of my image
enter image description here
and the location which is shows on the browser
enter image description here
how to solve this issue
New contributor
Suraj Maurya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.