Couldn't you just do multiple routes? (That saves a trip to the DB to verify)..
But I don't know the routes. I want to catch the URI, check the slug in the DB, and use the correct controller (page, news, etc) accordingly to the page type. The problem is that the news page can have any slug (/news, /hot-news, /noticias, etc). I need to check it in the DB to check the page type of that record and use the correct controller or model.
This way I'm not forced to use /news to load the News controller in all languages. I want to use the slug from the menu item and check it's page type. Then load the correct controller, model, view...
I'm thinking in maybe using a frontend controller to check the slug and correspondent page type, then redirect to the correspondent controller... But it doesn't feel solid...
Hmm, well, then you have to do a lookup for your page type and then slug (or maybe in the same lookup).. ? Do you have a github project for this? :)
ClausMunch said:
Hmm, well, then you have to do a lookup for your page type and then slug (or maybe in the same lookup).. ? Do you have a github project for this? :)
Not yet... I'm thinking in having a table in my DB with all possible page types and the correspondent Controller. Then use a "catch all" route to a controller that checks the page type for a given uri in the pages table.
Something like this: https://gist.github.com/fana605/85e4da394105ede0200c
This way, when a request is made to /latest-news, I have to check the pages table for a matching slug a get the page type. Then check the page_types table and get the controller name. What comes next is my doubt: How to load the correct controller from the "catch all" controller.
I guess this is not the best way of doing it. Maybe I can loop the pages table in the routes files, assigning the correct controller for each page directly...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community