filament plugin menu-builder

Has anyone installed this plugin? I have installed it but when I go to the edit page of the menu builder. I get an error that the route (categories.show)is not defined. Anyone has an idea?
7 Replies
Lara Zeus
Lara Zeus4mo ago
do you mean this one? maybe ask in the plugin channel #datlechin-menu-builder
Alnuaimi
Alnuaimi4mo ago
you mean categories.view?
raheel3031
raheel3031OP4mo ago
Yes that one Documentation said to use categories.show I already did that but no reply
Lara Zeus
Lara Zeus4mo ago
I am not sure where it been used but I think in the getMenuPanelUrlUsing return whatever works for your app. do you have a route named categories.*?
raheel3031
raheel3031OP3mo ago
Yes I did. Anyone?????
Lara Zeus
Lara Zeus3mo ago
we need more details about the error check art route:list and make sure the route name is the same you can (for testing) change the route (categories.show) to url(categories.show) to see if the error still persist and the best one to help you ofc is the author of the package 🙂
raheel3031
raheel3031OP3mo ago
in AdminPanelProvider
` ->plugin(FilamentMenuBuilderPlugin::make()
->addLocations([
'header' => 'Header',
'footer' => 'Footer',
])
->addMenuPanels([
StaticMenuPanel::make()
->add('Home', url('/'))
->add('Blog', url('/blog')),
ModelMenuPanel::make()
->model(\App\Models\Category::class)
->description('Lorem ipsum...')
->icon('heroicon-m-link')
->collapsed(true)
->collapsible(true)
->paginate(perPage: 5, condition: true),
])
` ->plugin(FilamentMenuBuilderPlugin::make()
->addLocations([
'header' => 'Header',
'footer' => 'Footer',
])
->addMenuPanels([
StaticMenuPanel::make()
->add('Home', url('/'))
->add('Blog', url('/blog')),
ModelMenuPanel::make()
->model(\App\Models\Category::class)
->description('Lorem ipsum...')
->icon('heroicon-m-link')
->collapsed(true)
->collapsible(true)
->paginate(perPage: 5, condition: true),
])
in filament-menu-builder.php
<?php

declare(strict_types=1);

return [
'tables' => [
'menus' => 'menus',
'menu_items' => 'menu_items',
'menu_locations' => 'menu_locations',
],
];
<?php

declare(strict_types=1);

return [
'tables' => [
'menus' => 'menus',
'menu_items' => 'menu_items',
'menu_locations' => 'menu_locations',
],
];
in Category.php
<?php

namespace App\Models;

use Datlechin\FilamentMenuBuilder\Contracts\MenuPanelable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Category extends Model implements MenuPanelable

{
use HasFactory;

public function getMenuPanelTitleColumn(): string
{
return 'name';
}

public function getMenuPanelUrlUsing(): callable
{
return fn (self $model) => route('categories.show', $model->slug);
}

// You need to implement the missing method:
public function getMenuPanelName(): string
{
// Return a suitable name for the menu panel
return 'Categories';
}

// Implement the missing method
public function getMenuPanelModifyQueryUsing(): callable
{
return fn ($query) => $query->where('is_visible', true);
}
<?php

namespace App\Models;

use Datlechin\FilamentMenuBuilder\Contracts\MenuPanelable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Category extends Model implements MenuPanelable

{
use HasFactory;

public function getMenuPanelTitleColumn(): string
{
return 'name';
}

public function getMenuPanelUrlUsing(): callable
{
return fn (self $model) => route('categories.show', $model->slug);
}

// You need to implement the missing method:
public function getMenuPanelName(): string
{
// Return a suitable name for the menu panel
return 'Categories';
}

// Implement the missing method
public function getMenuPanelModifyQueryUsing(): callable
{
return fn ($query) => $query->where('is_visible', true);
}
in web.php
<?php

use App\Livewire\Categories;
use App\Livewire\HomePage;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', HomePage::CLass);
Route::get('/categories', Categories::CLass);
Route::get('/categories/{slug}', [Categories::class, 'show'])->name('categories.show');
<?php

use App\Livewire\Categories;
use App\Livewire\HomePage;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', HomePage::CLass);
Route::get('/categories', Categories::CLass);
Route::get('/categories/{slug}', [Categories::class, 'show'])->name('categories.show');
` can anyone take a look at this code code is working
Want results from more Discord servers?
Add your server