Php 仅在登录时显示名称-laravel

Php 仅在登录时显示名称-laravel,php,laravel,Php,Laravel,如何仅在您登录时显示名称 @if($user = Auth::user()) {{ Auth::user()->name . " " . Auth::user()->last_name }} <i class="fe fe-check-circle ml-1 text-success tx-11"></i></h2> @endif 请提供帮助这应该可以: @if (!Auth::guest()) {{ Auth::user()-

如何仅在您登录时显示名称

@if($user = Auth::user())
    {{ Auth::user()->name . " " . Auth::user()->last_name }} <i class="fe fe-check-circle ml-1 text-success tx-11"></i></h2>
@endif
请提供帮助这应该可以:

@if (!Auth::guest()) 
    {{ Auth::user()->name . " " . Auth::user()->last_name }}
@endif
这应该起作用:

@if (!Auth::guest()) 
    {{ Auth::user()->name . " " . Auth::user()->last_name }}
@endif

你也可以这样做

@if(auth()->check())
  {{ optional(auth()->user())->name . " " . optional(auth()->user())->last_name }}
@endif 

and if you have multiple guards on your application then you should use 

@if(auth('guard_name')->check())
  {{ optional(auth('guard_name')->user())->name . " " . optional(auth('guard_name')->user())->last_name }}
@endif

希望它能起作用。

你也可以这样做

@if(auth()->check())
  {{ optional(auth()->user())->name . " " . optional(auth()->user())->last_name }}
@endif 

and if you have multiple guards on your application then you should use 

@if(auth('guard_name')->check())
  {{ optional(auth('guard_name')->user())->name . " " . optional(auth('guard_name')->user())->last_name }}
@endif

希望它能起作用。

请参阅下面的代码,了解根据


请参阅下面的代码,以了解根据