filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.18k stars 2.84k forks source link

Custom page not showing in cluster navigation #12976

Closed mattyforth closed 4 months ago

mattyforth commented 4 months ago

Package

filament/filament

Package Version

v3.2.63

Laravel Version

v11.2.0

Livewire Version

v3.4.10

PHP Version

8.3.0

Problem description

Hello!

I have a custom cluster called LegalCase, and within that cluster I have a CaseResource with the regular pages, list, view etc.

My LegalCase model has a status and can be pending, and I have created a custom page to just show the pending cases by modifying the query.

<?php

namespace App\Filament\Clusters\LegalCase\Resources\CaseResource\Pages;

use App\Filament\Clusters\LegalCase;
use App\Filament\Clusters\LegalCase\Resources\CaseResource;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Table;

class ListPendingCases extends ListRecords
{
    protected static string $resource = CaseResource::class;

    protected static ?string $cluster = LegalCase::class;

    protected static ?string $navigationLabel = 'Pending cases';

    public function table(Table $table): Table
    {
        return CaseResource::table($table)->description('Hello');
    }
}
    // CaseResource.php
    public static function getPages(): array
    {
        return [
            //...
            'pending' => ListPendingCases::route('/pending'),
        ];
    }

The page itself works fine when I navigate manually to the route I've defined, however it won't show up in the LegalCase cluster navigation, which according to the docs, I'm certain it should?

Expected behavior

The page should be visible in the clusters sub navigation menu.

Steps to reproduce

  1. Pull repo
  2. php artisan serve
  3. Migrate & seed
  4. Navigation to /admin and login
  5. Click "Legal case" navigation menu item
  6. See that there is no option for "pending cases" under the "your cases" item.
  7. Navigation to the /admin/legal-case/cases/pending page manually and see that the page is working (you should see a "pending" description on the table)
  8. View the code inside app/Filament/Clusters/LegalCase/Resources/CaseResource/Pages/ListPendingCases.php to verify that $cluster is set to LegalCase::class

Reproduction repository

https://github.com/mattyforth/filament-cluster-navigation-issue

Relevant log output

No response

alexmanase commented 4 months ago

Your class ListPendingCases should extend Resource, not ListRecords.

alexmanase commented 4 months ago

Here is the fix: https://github.com/mattyforth/filament-cluster-navigation-issue/pull/1/files

danharrin commented 4 months ago

It should actually extend Page, this isn't a resource @alexmanase

Make a page with make:filament-page and then add a table using https://filamentphp.com/docs/3.x/tables/adding-a-table-to-a-livewire-component