tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.86k stars 247 forks source link

It is not able to use the route filter. #645

Closed Ferks-FK closed 1 year ago

Ferks-FK commented 1 year ago

Ziggy version

1.6

Laravel version

9.19

Description

I am trying to filter the routes according to the route accessed according to this part of the guide.

I'm trying to make use of the groups, but it's not working anyway. I have 2 layouts, one for unauthenticated users (app) and one for admins (admin). Here is my config/ziggy.php.

'groups' => [
        'admin' => ['admin.*'],
        'app' => [
            'home.index',
            'auth.*',
            'servers.*',
            'bans.*',
            'mutes.*',
            'report.*',
            'appeal.*',
            'steam.*',
            'locales.*'
        ]
    ],
    'except' => [
        'debugbar.*',
        'ignition.*'
    ]
// app.blade.php
@routes('app')

// admin.blade.php
@routes('admin')

All my routes are group-based. No matter how much I use the app layout, all the administration routes are visible.

Ziggy call and context

In all my React components.

Ziggy configuration

I don't have any relevant settings.
I have just that in my HandleInertiaRequest Middleware:

'ziggy' => function () use ($request) {
  return array_merge((new Ziggy)->toArray(), [
     'location' => $request->url()
  ]);
},

Route definition

Route::name('admin.')->group(function() {
   Route::group(['prefix' => 'admin_settings'], function() {
        Route::get('/', [AdminController::class, 'index'])->name('settings.index');
        Route::get('/create', [AdminController::class, 'create'])->name('settings.create');
        Route::get('/{id}', [AdminController::class, 'show'])->name('settings.show');
        Route::post('/store', [AdminController::class, 'store'])->name('settings.store');
        Route::patch('/update/{id}', [AdminController::class, 'update'])->name('settings.update');
        Route::delete('/{id}', [AdminController::class, 'destroy'])->name('settings.destroy');
    });
    .....much more

}