Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel 5 routes where in group

I wanna create url like this

http://example.com/url1/product/blabla http://example.com/url2/product/aiueo

I can't achieve with this

Route::prefix('{page}')->name('the_url')->group(function () {
    Route::get('/', 'HomeController@page')
        ->name('index');

})->where('page', '(url1|url2)');

Or should I use the where() in every method inside the {page} prefix?

like image 609
ilubis Avatar asked Oct 20 '25 12:10

ilubis


1 Answers

You can use it with group like this:

Route::group([
    'as' => 'the_url',
    'prefix' => '{page}', 
    'where' => [
        'page' => 'url1|url2'
    ],
], function () {
    // Group routes
});
like image 155
DevK Avatar answered Oct 23 '25 03:10

DevK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!