Reputation: 45
I would like to call one function from a controller to all route begin with my_website/doc/.
But I can't find something that to do that in laravel 5.
something like: Route::get('my_website/doc/*', 'WelcomeController@doc');
for exemple:
my_website/doc/test --> WelcomeController@doc
my_website/doc/test/1 --> WelcomeController@doc
my_website/doc/test/1/etc --> WelcomeController@doc
Upvotes: 1
Views: 607
Reputation: 2989
This is another approach to solve the problem:
Route::get('{slug}', function($slug){
dd($slug);
//
})->where('slug', 'my_website/docs.*');
Upvotes: 1
Reputation: 657
You can use like this
Route::get('my_website/docs/{page?}', 'WelcomeController@doc');
{page?}
will be
test
for my_website/doc/testtest/1
for my_website/doc/test/1test/1/etc
for my_website/doc/test/1/etcAt doc
method
public function doc($page = null)
{
dd($page);
}
Upvotes: 1