Laravel-Backpack/MenuCRUD

MenuItem::getTree() method didn't return page link

morcano opened this issue · 5 comments

I created page and menu item and try display it in menu section.
In my case getTree() method didn't return page link.

dd(MenuItem::getTree()):
...
"name" => "Test"
"type" => "page_link"
"link" => null  // <--return null
"page_id" => 8

What could be the problem?

Is the information in the database? How does that row look in the DB?

Yes. When I add menu item with "page_link", in DB this record has null in "link" field.
bug

Can anybody update on this issue. as there is no help available on stack overflow as well.

@OwenMelbz I had also tried on a new project and can confirm that its not working as expected.

And since i am using the package and installing it using composer, i don't see any purpose of following.

I would recommend you read up on laravels relationships system https://laravel.com/docs/5.4/eloquent-relationships, check your $fillable and $guarded are correct as per https://laravel.com/docs/5.4/eloquent#mass-assignment - and make sure all your table conventions are correct https://laravel.com/docs/5.4/eloquent#eloquent-model-conventions

Hi @morcano and @acharyasarvesh ,

I think I now understand what the confusion was.

When a link to a page is stored, we don't store the actual link, as that might change it time (the page's slug). We store the ID of that page, in page_id. So yes, link will be empty.

When you output your menu, for page links get the link ar rendering. If you're using Backpack\PageManager, for example, instead of echoing $menu_item->link, echo $menu_item->page->getPageLink().

Hope it helps.

Cheers!