-1

When i click the link on my site to go to a page , it gives me an error 500 message, when i check the error it comes back with

Trying to get property of non-object' pointing towards 'return $next($request);',

please can someone help me out, thanks in advance, Here is the page's code

<?php

namespace App\Http\Middleware;

use Closure;

class StaffAuth
{
    /**
     * Handle an incoming request by checking to see if the user is a member of Staff.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure                 $next
     *
     * @return mixed
     */

public function handle($request, Closure $next)
    {
        if (is_null($request)) {
            return redirect('/')->with('flash_error', 'Could not access, No Session Found.');
        }

        if (is_null($request->user())) {
            return redirect('/')->with('flash_error', 'You have been automatically logged out due to an extended period of inactivity.');
        }

        if (! $request->user()->isStaff()) {
            return redirect('/')->with('flash_error', 'Could not access, Permission Denied');
        }

        return $next($request);
    }
}

Error

  • Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – AymDev Sep 05 '18 at 09:25
  • 1
    Post complete error with trackback code, so that we can provide a solution – Waqar Sep 05 '18 at 09:27

1 Answers1

0

I don't think the error is where you're pointing. Probably these errors happen in blade views as you may trying to access a property of a null object.

Yamen Ashraf
  • 2,637
  • 2
  • 20
  • 26