我试图在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值的正确方法。我做错了什么?
答案 0 :(得分:1)
所以而不是
use Request;
尝试
use Illuminate\Http\Request;
答案 1 :(得分:1)
而不是使用
use Request;
使用Illuminate \ Support \ Facades \ Request
使用
use Illuminate\Http\Request;