Answer the question
In order to leave comments, you need to log in
Where to set a link to the default image?
Got a question.
There are social network. Users have avatars that they have set, or default ones if they have not.
Now a question. At the moment, the output of the avtarka looks like this:
@if($user->description->user_profile_avatar)
<img src="{{$user->description->user_profile_avatar}}" alt=""><br>
@else
<img src="img/default.png" alt=""><br>
@endif
Answer the question
In order to leave comments, you need to log in
the concept of "correct / incorrect" does not exist, the solution is quite normal, the blade will do its job in this case, it is actually created for this, if it is implemented at the model level, then the condition will go into the model)))
Proceeding from the logic: the task for the front Yes, this is the best approach
Well, if the user is initially assigned a picture by default as an avatar? And then output $user->description->user_profile_avatar without any checks. And then transfer the verification logic already at the moment where the user deletes his photo, again replacing the avatar with the default picture.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question