Answer the question
In order to leave comments, you need to log in
How to collect dynamic Urls in Laravel?
Let's say there are routes
Route::get('parking-lot-atl', '[email protected]')->setParamets('id' => 1);
Route::get('parking-best-lot', '[email protected]')->setParamets('name' => 'name');
...
Route::get('some-name', '[email protected]')->setParamets('parametr' => n);
I want to store the URLs of the entire site in the database
. I want to collect the correct URL through the URL facade.
Can Laravel do this?
Worked with yii - he knew how. And I can't find it here.
Based on an example
Route::get('test-airport-parking-{lot}', '[email protected]')->name('test')->where('lot', '[0-9]+');
Route::get('test2-airport-parking-{lot}', '[email protected]')->name('test')->where('lot', '[10-19]+');
\URL::action('[email protected]', ['lot' => 2])
\URL::action('[email protected]', ['lot' => 12])
Answer the question
In order to leave comments, you need to log in
The question is not entirely clear, but still I will try to answer:
1) If you want to build a url to a specific article, then when creating a route, you must specify a name for it, and then call:
2) If you have a table in the database and you need from it create routes, then:
2.1) Create a Page model
2.2) Create a PageController
class PageController extends Controller {
public function show($slug)
{
$page = Page::whereSlug($slug)->firstOrFail();
return view('pages.' . $page->view);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question