2
Laravel: v5.7.28
Voyager: v1.2.0
PHP: 7.2
Database: MySQL 8.0

I setup Voyager Admin Panel on my Laravel E-commerce. When I try to login, I see an error:

(1/1) BadMethodCallException Method Illuminate\Http\Request::validate does not exist.

Stack:

--
in Macroable.php line 100
at Request->__call('validate', array(array('email' => 'required\|string', 'password' => 'required\|string')))in AuthenticatesUsers.php line 68
at VoyagerAuthController->validateLogin(object(Request))in VoyagerAuthController.php line 24
at VoyagerAuthController->postLogin(object(Request))
at call_user_func_array(array(object(VoyagerAuthController), 'postLogin'), array(object(Request)))in Controller.php line 54
at Controller->callAction('postLogin', array(object(Request)))in ControllerDispatcher.php line 45
at ControllerDispatcher->dispatch(object(Route), object(VoyagerAuthController), 'postLogin')in Route.php line 219
at Route->runController()in Route.php line 176
at Route->run()in Router.php line 682
at Router->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request))in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in VerifyCsrfToken.php line 75
at VerifyCsrfToken->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in StartSession.php line 63
at StartSession->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in EncryptCookies.php line 66
at EncryptCookies->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 104
at Pipeline->then(object(Closure))in Router.php line 684
at Router->runRouteWithinStack(object(Route), object(Request))in Router.php line 659
at Router->runRoute(object(Request), object(Route))in Router.php line 625
at Router->dispatchToRoute(object(Request))in Router.php line 614
at Router->dispatch(object(Request))in Kernel.php line 176
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request))in InjectDebugbar.php line 65
at InjectDebugbar->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in CheckForMaintenanceMode.php line 62
at CheckForMaintenanceMode->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 104
at Pipeline->then(object(Closure))in Kernel.php line 151
at Kernel->sendRequestThroughRouter(object(Request))in Kernel.php line 116
at Kernel->handle(object(Request))in index.php line 55

Error in Laravel https://github.com/laravel/framework/blob/6.x/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php#L67

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

I check the documentation https://laravel.com/docs/5.7/validation and it's correct code. Please help, why doesn't it work?

1
  • 1
    Can you share your complete LoginController ? Commented Sep 20, 2019 at 2:03

2 Answers 2

1

i don't proper reason for this but i faced same issue after update to 5.6. Use

use Request;

instead of

 use Illuminate\Http\Request;

this works for me

Sign up to request clarification or add additional context in comments.

Comments

0

You should use $this->validate(); method and pass in $request as the first parameter

or, you can use the Validator::make(); method and pass in $request as the first parameter

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.