Answer the question
In order to leave comments, you need to log in
How to display general profile information on multiple templates?
Hello.
How in laravel 5.2 to implement the output of general information in several templates?
route
Route::get('/profile/{username}', '[email protected]')->name('profile.show');
Route::get('/profile/{username}/edit', '[email protected]')->name('profile.edit');
/**
* Show User Profile.
*
* @param $username
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showProfile($username)
{
$user = User::where('username', '=', $username)->firstOrFail();
return view('profile.activity', compact('user'));
}
/**
* Edit user information
*
* @param $username
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function editProfile($username)
{
$user = User::where('username', '=', $username)->firstOrFail();
return view('profile.settings', compact('user'));
}
Answer the question
In order to leave comments, you need to log in
Everything is correct. Use ComposerView . Have you read the documentation? it 's pretty well laid out here.
You attach a handler to a certain view, which will work and slip data there every time this view is used.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question