Life4Cali Life4Cali - 7 months ago 35
PHP Question

Laravel 5 Illuminate\Http\Request has method not allowing static call

I'm trying to call the Illuminate\Http\Request has method from one of my controllers.

Request::has('fields')


Following from the documentation exactly, yet I'm getting an error thrown:

Non-static method Illuminate\Http\Request::has() should not be called statically, assuming $this from incompatible context

I'm not sure what I'm doing wrong here, I tried following the documentation as closely as possible.

Answer

The problem is you are using the wrong Request class. You need to import the Facade:

use Illuminate\Support\Facades\Request;
Comments