这就是HolidaysController
目前的样子:
public function _construct(){
$this->middleware('auth');
}
/**
* Display a listing of the holidays.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// get all the holiday requests from the database
$holidayReq = HolidayRequest::all();
// load the view and pass the holiday requests
return view('holidays.index')->with('holidayRequests',$holidayReq);
}
auth
中间件是样板Laravel中间件,我没有改变它。
一旦我注销然后尝试访问/holidays
路由,这导致上面的index()
方法,我得到以下ErrorException,而不是它应该进入登录页面:
Trying to get property of non-object (View: *followed by long address of the blade file
我已经多次刷新Apache了,但它似乎仍然无法正常工作。
答案 0 :(得分:2)
您定义为构造函数的方法不是PHP中的构造函数。
_construct != __construct