Laravel 5.1 调用未定义的方法 Illuminate\Support\Facades\Request::cookie()
Laravel 5.1 Call to undefined method Illuminate\Support\Facades\Request::cookie()
我试图在 Laravel 5.1 中的控制器中加载 cookie 的值,但出现此错误:
FatalErrorException in SurveyController.php line 21: Call to undefined method Illuminate\Support\Facades\Request::cookie()
这是我的代码:
<?php
namespace App\Http\Controllers;
use Response;
use Request;
use Illuminate\Routing\Controller;
use Cookie;
use Log;
class SurveyController extends Controller {
/**
* Index method. Decide to resume a survey or start a new one.
*/
public function index(Request $request) {
dd($request->cookie('survey_id'));
}
}
据我所知 the documents,这似乎是加载 cookie 值的正确方法。我做错了什么?
所以而不是
use Request;
尝试
use Illuminate\Http\Request;
而不是使用
use Request;
它使用 Illuminate\Support\Facades\Request
使用
use Illuminate\Http\Request;
我试图在 Laravel 5.1 中的控制器中加载 cookie 的值,但出现此错误:
FatalErrorException in SurveyController.php line 21: Call to undefined method Illuminate\Support\Facades\Request::cookie()
这是我的代码:
<?php
namespace App\Http\Controllers;
use Response;
use Request;
use Illuminate\Routing\Controller;
use Cookie;
use Log;
class SurveyController extends Controller {
/**
* Index method. Decide to resume a survey or start a new one.
*/
public function index(Request $request) {
dd($request->cookie('survey_id'));
}
}
据我所知 the documents,这似乎是加载 cookie 值的正确方法。我做错了什么?
所以而不是
use Request;
尝试
use Illuminate\Http\Request;
而不是使用
use Request;
它使用 Illuminate\Support\Facades\Request
使用
use Illuminate\Http\Request;