mercredi 23 septembre 2015

Get $request variabel in route function - laravel?

I have this route

Route::post('/unicorn',['as' => 'unicorn',function ()
{
    //Despite popular belief unicorns can be controlled
    $pony = $this->app->make('App\Http\Controllers\UnicornController')->saddle(); 
}]);

And I also have a good reason to be making the controller within the route function instead of just using 'uses' => 'UnicornController'.

The issue arises from the fact that the saddle() function requires the request

public function saddle(Request $request){
    dd($request->input('type'));
}

So... how can I

A. ideally be able to access $request within the route function

or

B. Get $this->app->make() to inject the request like using 'uses' => does

..?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire