Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()

like image 992
chimpurok Avatar asked Oct 24 '25 17:10

chimpurok


2 Answers

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

like image 151
Jacob Barrow Avatar answered Oct 27 '25 03:10

Jacob Barrow


There is also possible ways to use

use Illuminate\Http\Request;

instead of

use Illuminate\Support\Facades\Request;

at the top. hide "use Illuminate\Support\Facades\Request;"

Hope it works. Thank you.

like image 23
Solomon Suraj Avatar answered Oct 27 '25 03:10

Solomon Suraj