Patrick L.
Patrick L.

Reputation: 526

Basic Laravel 4 Routing

I would like to call a controller with parameters with this kind of configuration:

Route::pattern('d', '[0-9]+');

Route::get('/{a}/{b}/{c}/{d}', function($a, $b, $c, $d)
{
    // CALL A METHOD OF A CONTROLLER WITH PARAMETERS
});

Upvotes: 1

Views: 393

Answers (1)

Daniel Gasser
Daniel Gasser

Reputation: 5133

Just call the controller method like this:

Route::get('/{a}/{b}/{c}/{d}', 'AnyController@itsMethod');

And in the controller:

class AnyController extends BaseController {
    //...
    public function itsMethod($a, $b, $c, $d) {
        ///proceed your params
    }
    //...
}

Laravel passes route-variables like '/{a}/{b}/... as parameter(s) to the called controller-method.

Upvotes: 1

Related Questions