I am having trouble to get all the information that I need for my pages on my local system.
For now I have a routes and a pages table which both hold a “slug” column.
But I want to get rid of the “slug” column from the pages table and link the pages table to the routes table.
I think what might be confusing and making things difficult is that the model names should be singular. Also if a page only has one route than the association method should be named “page” not pages. I’m not sure whether that makes a difference but if that was corrected the syntax would be something like this.
$pages = App\Page::with(['route' => function ($query) use ($route) {
$query->where('slug',$route);
}])->get();
I will check both out.
What I’m doing is basically instead of putting al routes in the routes file, I save the in the DB.
Then I check if the route exists.
But I now have 2 slug columns while I maybe only need one.
If I can check if the routes_id on the pages table matches the id from the routes table.