Hello

I am trying to do authentication in Laravel, but after filling in the fields in the authorization form, an error pops up: enter image description here

and there below is a whole bunch of everything else - like a snowball ...

Here are the routes:

// Маршруты аутентификации... Route::get('auth/login', 'Auth\AuthController@getLogin'); Route::post('auth/login', 'Auth\AuthController@postLogin'); Route::get('auth/logout', 'Auth\AuthController@postLogin'); // Маршруты регистрации... Route::get('auth/register', 'Auth\AuthController@getRegister'); Route::post('auth/register', 'Auth\AuthController@postRegister'); 

And the error itself occurs in this place:

 protected function validateLogin(Request $request) { $this->validate($request, [ $this->loginUsername() => 'required', 'password' => 'required', ]); } 

I do not understand where I get this method validate? Because everything was created not manually, but simply using php artisan make:auth

    1 answer 1

    This method is in the \Illuminate\Foundation\Validation\ValidatesRequests , which should be connected to the main controller \App\Http\Controllers\Controller .

    If something is removed - return. Or simply add use ValidatesRequests to the controller.

    • Already connected namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesResources; use App\Models\Flats; namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesResources; use App\Models\Flats; - DumbSailor
    • What you copied is the connection of namespaces. Inside the class should also be use ValidatesRequests; - xEdelweiss
    • Thank you very much, by chance, apparently the line was captured while commenting, Inattention .. - DumbSailor