Skip to content
Advertisement

how to bind multiple related parameters in one route in laravel

I have Two related Models Anime, Episode

and I have changed the RouteKeyName for both of them

In Anime Model :

JavaScript

In Episode Model :

JavaScript

to view an Episode, I use this :

routes/web.php

JavaScript

EpisodeController.php

JavaScript

for example if i have this link

…/play/naruto/10

then by using route model binding i will have the first episode with ep_num=10

Instead I want to have the episode with ep_num=10 when

JavaScript

is there any way to do this inside RouteServiceProvider

i want to apply this for all the routes containing both anime and episode such as :

JavaScript

Advertisement

Answer

You could do something like:

JavaScript

Hope this helps!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement