What is the best practice, for example to show user data?
-
Retrieve user in show function inside UserContoller, and pass user variable to the view?
-
Return view in show function, passing the $user_id, and retrieve the user on the view?
Example 1:
public function show($id)
{
$user = User::findOrFail($id);
return view('config.users.show')->withUser($user);
}
Example 2:
public function show($id)
{
return view('config.users.show')->withId($id);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire