V
V
vism2017-05-29 19:49:39
Laravel
vism, 2017-05-29 19:49:39

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])

I want to receive 2 different urls, respectively, but the last one is always returned.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Prosvetov, 2017-05-29
@Dragomeat

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);
               }
              }

2.3) Create a main route
Sorry if I misunderstood)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question