Class 'Backpack\MenuCRUD\app\Models' not found
shinokada opened this issue · 8 comments
What I did:
I used method B to install MenuCRUD.
I successfully added some menus in Backpack.
In the front end, I followed the doc.
I have the following code:
<!-- Navigation -->
<nav id="menu" class="menu-main-menu-container" aria-label="Navigation" itemscope itemtype="https://schema.org/SiteNavigationElement">
<ul id='menu-main-menu' class='menu'>
@foreach (Backpack\MenuCRUD\app\Models::getTree(); as $item)
<a class="no-underline hover:underline p-3"
href="{{$item->url()}}">
{{ $item->name }}
</a>
@endforeach
</ul>
</nav>
<a class="responsive-menu-toggle" href="#"><i class='fa fa-reorder'></i></a>
What happened:
It returns an error:
Error
Class 'Backpack\MenuCRUD\app\Models' not found (View: /Applications/MAMP/htdocs/codewithshin-laravel/resources/views/pages/partials/navigation.blade.php)
Backpack, Laravel, PHP, DB version:
Backpack: v4
Laravel: 8.40.0
PHP: 7.4.12
DB: 5.7.32 - MySQL Community
Hello @shinokada
Easy to spot error. @foreach (Backpack\MenuCRUD\app\Models::getTree(); as $item)
should be @foreach (Backpack\MenuCRUD\app\Models\Menu::getTree(); as $item)
I am going to close this as I think there is no bug here.
Best,
Pedro
@shinokada use \Backpack ...
note the backslash before Backpack
.
Sorry, my bad, the name is MenuItem
and not Menu
. \Backpack\MenuCRUD\app\Models\MenuItem
Best,
Pedro
@shinokada totally. Where in docs did you found it ? I only found in README.md
and it's correct.
Can you point me where you saw it was incorrect ?
Thanks,
Pedro
It must be my mistake then.
But when I use \App\MenuItem::getTree()
, I get an error though.