samedi 15 octobre 2016

Laravel 5 : Does Auth::user() query the database everytime I use it?

On the edit profile page for a user, I want to show the existing values of the current logged-in user details like name, email, gender etc. My questions are as follows

  1. Is it recommendable to user Auth::user()->name , Auth::user()->email directly to populate the form fields ? Or shall I create a variable like $user = Auth::user(); in my controller and pass it on to my view to $user like a regular object?
  2. Does using Auth::user(), multiple times on a given view file hit my database each time I use it?

    Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire