Search code examples
phplaravel-5.4laravel-5.5

How {{ Auth::user()->name }} is able to print username in blade file?


I have been working in default authentication features in laravel..I found in one blade file Auth::user()->name is able to display name stored in user table..But what i want to know is how it is able display name in blade with an eloquent call.


Solution

  • You can use it like this.

    auth()->user()->some_column

    Check your user table in your database and use the appropriate column name.

    You can use it in blade file like this. {{ auth()->user()->some_column }}

    If you're going to use this in a conditional statement like IF, you can use it like this.

    @if(auth()->user()->some_column)