laravel-5request

Call to undefined method Illuminate\Support\Facades\Request::all()


I am using session in Laravel 5.1 and here is my Controller code :

Route::post('/task', function (Request $request) {
    $validator = Validator::make($request->all(), [
        'name' => 'required|max:255',
    ]);

    if ($validator->fails()) {
        return redirect('/')
            ->withInput()
            ->withErrors($validator);
    }

   
});

I need to use session, and getting this error : Call to undefined method Illuminate\Support\Facades\Request::all()


Solution

  • Make sure you're importing the right Request class at the top of the file:

    use Illuminate\Http\Request;

    At the moment it looks like you're using the Request facade