jeudi 18 avril 2019

"Trying to get property 'headers' of non-object" Middleware\VerifyCsrfToken.php:180

I wrote my custom middleware, but when it is executed, the error appears. Middleware:

namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use App\Employee;

class CheckConfirm
{
public function handle($request, Closure $next)
{
    if(Auth::check())          
    {
        $id = Auth::id();        
        $empl = Employee::where('user_id','=', $id)->get();
        if($empl->isEmpty())
        {
            return route('confirm');                    
        }
        else
        {                
            dump($empl);
            return $next($request);
        }
    }
    else
    {
        return route('login');
    }
}

} When I try something like this:

if($empl===null)
   {
      return route('confirm');                    
   }

сondition just doesn't work. In this case, database queries are executed successfully. Here is the error page with dump



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire