jeudi 26 mai 2016

Best practice for show data inside Laravel view

What is the best practice, for example to show user data?

  1. Retrieve user in show function inside UserContoller, and pass user variable to the view?

  2. 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