试图获取非对象的属性

时间:2018-09-05 09:23:02

标签: php

当我单击网站上的链接转到页面时,它给我一条错误500消息,当我检查该错误时,它会以

出现
  

试图获取非对象的属性”,指向“返回$ next($ request);”,

请有人可以帮助我,在此先感谢, 这是页面的代码

<?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

1 个答案:

答案 0 :(得分:0)

我认为错误不是您要指出的。当您尝试访问空对象的属性时,这些错误可能会在刀片视图中发生。