Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method Illuminate\Http\Request::first does not exist in laravel 6 #32702

Closed
kabircse opened this issue May 6, 2020 · 3 comments
Closed

Method Illuminate\Http\Request::first does not exist in laravel 6 #32702

kabircse opened this issue May 6, 2020 · 3 comments

Comments

@kabircse
Copy link

kabircse commented May 6, 2020

  • Laravel Version: 6.18.13
  • PHP Version: 7.2.19
  • Database Driver & Version: MySQL-5.7.24

Description:

Last year I have created a project in laravel 6. The project is working fine.
Some days ago, I added "fruitcake/laravel-cors" package and run errors command
php artisan vendor:publish --tag=laravel-errors.

After that I am getting error in laravel default register page and getting error when login credentials is wrong. If login credentials is true there is no error.

The error is:
[2020-05-06 17:16:33] production.ERROR: Method Illuminate\Http\Request::first does not exist. {"exception":"[object] (BadMethodCallException(code: 0): Method Illuminate\Http\Request::first does not exist. at D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Support\Traits\Macroable.php:103)
[stacktrace]
#0 D:\Laragon\www\my-gas\app\Exceptions\Handler.php(55): Illuminate\Http\Request->__call('first', Array)
#1 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(51): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(Illuminate\Validation\ValidationException))
#2 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(132): Illuminate\Routing\Pipeline->handleException(Object(Illuminate\Http\Request), Object(Illuminate\Validation\ValidationException))
#3 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#4 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 5, '10')
#5 D:\Laragon\www\my-gas\app\Http\Middleware\RedirectIfAuthenticated.php(24): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#6 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#7 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php(41): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#8 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#9 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php(76): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#10 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#11 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(56): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#15 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#16 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#17 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php(66): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#18 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Routing\Router.php(683): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#21 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Routing\Router.php(658): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#22 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Routing\Router.php(624): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#23 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Routing\Router.php(613): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#24 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(170): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#25 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#26 D:\Laragon\www\my-gas\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php(58): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 D:\Laragon\www\my-gas\vendor\fruitcake\laravel-cors\src\HandleCors.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 D:\Laragon\www\my-gas\vendor\fideloper\proxy\src\TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(145): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#42 D:\Laragon\www\my-gas\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#43 D:\Laragon\www\my-gas\public\index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#44 D:\Laragon\www\my-gas\server.php(21): require_once('D:\\Laragon\\www\\...')
#45 {main}
"}

Steps To Reproduce:

@GrahamCampbell
Copy link
Member

Thanks for getting in touch. Please report this bug to the maintainers of fruitcake/laravel-cors. :)

@kabircse
Copy link
Author

kabircse commented May 6, 2020

Thanks for getting in touch. Please report this bug to the maintainers of fruitcake/laravel-cors. :)

After remove fruitcake/laravel-cors , yet the problem exist. If I use validate as complex, if input data validation has error then same request error shows on log, If input data has no validation error, then there is same error(Request::first) happening.

This gives me error Request::first error on log,if title and created_by is duplicate.

$created_by = auth()->user()->id;
    $this->validate($request, [
        'title' => 'required|max:50|unique:register_types,title,null,id,created_by,'.$created_by
    ]);

But this gives me Validation error correctly as Title is already taken at same input:

$validator = \Validator::make($request->all(),[
        'title' => 'required|max:50|unique:register_types,title,null,id,created_by,'.$created_by
    ]);
    if ($validator->fails()) {
        return $validator->errors();
    }

I think there is version mismatch problem in Request or Macroable ....

@kabircse
Copy link
Author

kabircse commented May 6, 2020

Thanks for your comment. I got my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants