laravel - Why can Auth::user, DB::() and other statements be directly called in the blade template?
淡淡烟草味
淡淡烟草味 2017-05-16 16:55:35
0
1
724

I want to call Auth::user() in the controller, but it doesn't work at first.
After passing in the Guard class, it can be called, as follows
public function display(Request $request,Guard $auth) {
$email=$auth->user()->getEmail ();
//Other statements
}

But I can get it directly using {{Auth::user()->getEmail}} in the blade template.

淡淡烟草味
淡淡烟草味

reply all(1)
过去多啦不再A梦

If you are using Laravel, you can theoretically use Auth::user() directly in the controller. To get a user’s email, you can do this directly:

Auth::user()->email

When using it like this, remember to declare it in the class header:

use Auth;

Or write directly like this:

\Auth::user()->email
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template