Trouble setting and getting all info for pages

Hello everyone,

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.

Here is my gist so you can check it out.
https://gist.github.com/concept-core/15339fd92e124bb5e3f23f4d191f5063

Hopefully I explained it good enough.
( also asked on : http://laravel.io/forum/05-22-2016-trouble-setting-and-getting-all-info-for-pages )

Are possibly looking for a relationship between pages and routes?

Scott

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();
1 Like

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.

That part I cannot get to work properly.

I guess I don’t understand the problem. Can’t you just remove the existing one and use a different query.

Ok I think the code works how you intended it to work,
But it will not work for me.

Is there a way to get one page back that correspondents with the current url ?

I am getting this now :
https://gist.github.com/concept-core/30681b3029c98ae8cd0e786d87db70df

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.