1
votes

I want to achieve url like below as I am migrating old website to laravel but need to make same urls as previous.

http://example.com/garage-stalls-plans-plan10-4245

what I have done to generate url like this :

<a href="{{ $title.'-'.'plan'.$id1.'-'.$id2}}">Link</a>

and it is working fine but how to get $id and $id2 value in details page controller ?

here is my route

    Route::get('{title}-{id1}-{id2}', 'SearchController@details')
        ->where('title', '.*?')
        ->where('id1', '[0-9]')
->where('id2', '\d+')
;

Need to get 10 & 4245 in controller. If I remove second where '->where('id1', '[0-9]')' I am getting plan10 and 4245 perfectly. What If I want 10 and 4245 ?

Something like this Get the id from a slug Laravel 4

1

1 Answers

0
votes
Route::get('{slug}{id1}-{id2}', 'SearchController@details')
->where('slug', '[a-Z\-]+')
->where('id1', '[0-9]+')
->where('id2', '[0-9]+');

Try something like that