jeudi 16 février 2017

Laravel Route Model Binding: Check if a route parameter exists in model

I have this route:

Route::get('{country}/{federalstate?}/{city?}', ['as' => 'regions.show', 'uses' => 'RegionsController@show']);

Next i have a model Country with a few countries in it.

I want this route only to take effect, when given {country} exists in the model Country. I want to do this, because don't wan to use a prefix for that route.

The ugly way would be a regular expression. Ugly, because I would have to update it every time I add a new country to the model.

So what's the best way to accomplish what I want to do?

Maybe this could help -> http://ift.tt/2kDVPs0 - but I am a beginner, and I can't get it to work..



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kvENRQ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire