laravel route with auth user if not loggin

Viewed 29

I have this code in my laravel blade :

@if(Auth::check())
    <form 
        id="fileUploadForm" 
        method="POST" 
        action="{{route('scanningUpload',['user'=>Auth::user()->id,'person'=>$person->id])}}" 
        enctype="multipart/form-data"
    >
@else

<p> do some thing </p>

but now I got this error:

Attempt to read property "id" on null for Auth::user()->id

How can I fix it?

1 Answers
//try this
@auth
    // The user is authenticated...
@endauth
 
@guest
    // The user is not authenticated...
@endguest

For more please visit Laravel Documentation

Related