Answer the question
In order to leave comments, you need to log in
How to properly implement view return in Laravel?
I make a list of users, and their profiles, and here the question arose.
There is a page /users/{id}/ configured a route + controller, I give a view. Then the question arose to display another view if the page belongs to a logged in user.
Something tells me what to block in the controller in each method like this:
if(Auth::id() == $user->id) {
return view('profile.my.show', compact('user', 'departments', 'users'));
} else {
return view('profile.show', compact('user', 'departments', 'users'));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question