My application is made in laravel 5.8, I want to ask about the best approach for a unique scenario where I want to display some of my customer profiles like
I know that in laravel I have to give a unique identifier before the URL like https://www.example.com/profile/1234 so that it know which function to look for. But for some reason I have to build the above URL.
I tried it directly like:
Route::get('/{id}', 'ExampleController@myfunction')->name('profiler');
But this only works when I put it in bottom of my Routes file. If I place it somewhere in the middle or top. All other links like https://www.example.com/about-us stops working.
My Question is:
I would really want to use the URL I mentioned in the start of the question.
Thank you all in advance for helping me.
Peace :)
I think you can specify the type of {id} through regular expression.
Route::get('/{id}', function ($id) {
//
})->where('id', '[0-9]+');
this route will only work if id is numeric for
https://www.example.com/about-us
it the route will not work.
hope that's what you are looking for..