framework icon indicating copy to clipboard operation
framework copied to clipboard

Request::all(), always end on error

Open rapocalypse opened this issue 11 years ago • 2 comments

Hi,

I'm creating controllers using artisan command make:controller. So my controller files are partly ready.

I use a lot the Request::all() to get data on posts and gets, and the controller file created by artisan alredy came with the uses for App\Http\Requests; and Illuminate\Http\Request;

But when I call Resquest::all() on my function, I get this error: "Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context"

Off course I'm doing something wrong, but to fix it, the only way I know is to comment the mentioned calls, and add a use Request; only, as shown below.

// use App\Http\Requests; // use Illuminate\Http\Request; use Request;

Is this something wrong with artisan, or I'm really using Resquest in a wrong way?

thanks!

rapocalypse avatar Mar 12 '15 17:03 rapocalypse

Yeh, you're using it wrong. The request instance is Illuminate\Http\Request, but the facade is Illuminate\Support\Facades\Request. Make sense?

GrahamCampbell avatar Mar 12 '15 22:03 GrahamCampbell

Thanks @GrahamCampbell !

I read the docs on Laravel and I couldn't find why I'm using it wrong… I know this doesn't need to be explained here, but can you help?

Thanks, again :/

rapocalypse avatar Mar 13 '15 01:03 rapocalypse