Laravel Filament 3 Navigation Groupsと、Parent Navigation Items 学習メモ

Laravel Filament 3 Navigation Groupsと、Parent Navigation Items 学習メモ

Filament Navigation Groupsと、Parent Navigation Items

Navigation Groups

PostResource.php(変更)

$navigationGroup、$navigationSort の定義を追加。


class PostResource extends Resource
{
    protected static ?string $model = Post::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    protected static ?string $navigationGroup = "Blog";

    protected static ?int $navigationSort = 5;

    public static function form(Form $form): Form
    {
        return $form

参考に、

/home/ubuntu/laravel-blog-project/vendor/filament/filament/src/Resources/Resource.php

    protected static ?string $model = null;

    protected static ?string $navigationBadgeTooltip = null;

    protected static ?string $navigationGroup = null;

    protected static ?string $navigationParentItem = null;

以下のようにナビゲーション グループする事ができます。

Parent Navigation Items

$navigationParentItem の定義を追加。

PostResource.php(変更)


    protected static ?string $navigationGroup = 'Blog';

    protected static ?string $modelLabel = "Articles";

CategoryResource.php(変更)


    protected static ?string $modelLabel = "Post Categories";
    
    protected static ?string $navigationGroup = 'Blog';

    protected static ?string $navigationParentItem = "Articles";

CommentResource.php(変更)

    protected static ?string $navigationGroup = "User";

UserResource.php(変更)

    protected static ?string $navigationGroup = "User";