当我通过命令表格doc检查路线列表时:
php artisan route:list //RuntimeException: Session store not set on request.
我发现在session()
函数中应该更好地使用辅助函数$request->session()
而不是Controller __contract
。
class SomeController extends Controller
{
public function __construct(Request $request)
{
//use $request->session()->has($var) will occur the exception as this post said.
if (session()->has($var)) {
//do something;
}
}
}
答案 0 :(得分:2)
在控制器中使用session()
代替$request->session()
,例如:
class SomeController extends Controller
{
public function __construct(Request $request)
{
//use $request->session()->has($var) will occur the exception as this post said.
if (session()->has($var)) {
//do something;
}
}
}