### Install GitBook Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/SETUP.md Install GitBook in the current project directory. This command should be run after installing the GitBook CLI. ```bash gitbook install ``` -------------------------------- ### Install GitBook CLI Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/SETUP.md Install the GitBook command-line interface globally using npm. ```bash npm install -g gitbook-cli ``` -------------------------------- ### Serve GitBook Locally Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/SETUP.md Start a local development server to preview the GitBook documentation. The documentation will be accessible at http://localhost:4000. ```bash gitbook serve ``` -------------------------------- ### Install Package via Composer Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/installation.md Use this command to install the package via Composer. Choose the version that matches your Filament installation. ```bash composer require biostate/filament-menu-builder:^1.0 ``` ```bash composer require biostate/filament-menu-builder:^4.0 ``` ```bash composer require biostate/filament-menu-builder:^5.0 ``` ```bash composer require biostate/filament-menu-builder ``` -------------------------------- ### Install Filament Menu Builder for Filament v3 Source: https://github.com/biostate/filament-menu-builder/blob/main/README.md Use this composer command to install the package for Filament version 3. ```bash composer require biostate/filament-menu-builder:^1.0 ``` -------------------------------- ### Install Filament Menu Builder for Filament v5 Source: https://github.com/biostate/filament-menu-builder/blob/main/README.md Use this composer command to install the package for Filament version 5. ```bash composer require biostate/filament-menu-builder:^5.0 ``` -------------------------------- ### Install Filament Menu Builder for Filament v4 Source: https://github.com/biostate/filament-menu-builder/blob/main/README.md Use this composer command to install the package for Filament version 4. ```bash composer require biostate/filament-menu-builder:^4.0 ``` -------------------------------- ### Markdown Navigation Structure Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/SETUP.md Example of how to define the navigation structure for GitBook using markdown in SUMMARY.md. Supports nested subsections. ```markdown * [Page Title](filename.md) * [Subsection](filename.md#anchor) ``` -------------------------------- ### Publish and Run Migrations Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/installation.md Publish the package's migration files and then run the migrations to set up the necessary database tables. ```bash php artisan vendor:publish --tag="filament-menu-builder-migrations" php artisan migrate ``` -------------------------------- ### Build GitBook for Deployment Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/SETUP.md Build the static site for the GitBook documentation. This command generates a '_book' directory containing the deployable site. ```bash gitbook build ``` -------------------------------- ### Publish Configuration File Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/installation.md Optionally publish the configuration file to customize the package's behavior. ```bash php artisan vendor:publish --tag="filament-menu-builder-config" ``` -------------------------------- ### Publish Menu Views Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/blade-components.md Run this Artisan command to publish the package's views to your application. This allows for customization of menu rendering. ```bash php artisan vendor:publish --tag="filament-menu-builder-views" ``` -------------------------------- ### Run Package Tests Source: https://github.com/biostate/filament-menu-builder/blob/main/README.md Execute the test suite for the filament-menu-builder package using Composer. ```bash composer test ``` -------------------------------- ### Create GitHub Release Source: https://github.com/biostate/filament-menu-builder/blob/main/RELEASING.md Create a GitHub Release using the GitHub CLI, associating it with a tag and providing release notes. ```bash gh release create vX.Y.Z \ --title "vX.Y.Z" \ --notes "" ``` -------------------------------- ### Create Annotated Git Tag Source: https://github.com/biostate/filament-menu-builder/blob/main/RELEASING.md Create an annotated Git tag for a new release and push it to the remote repository. ```bash git tag -a vX.Y.Z -m "vX.Y.Z release notes..." git push origin vX.Y.Z ``` -------------------------------- ### Render Menu by Slug Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/blade-components.md Use this component to render a menu using its unique slug. Ensure the slug corresponds to an existing menu. ```html ``` -------------------------------- ### Register Models in Configuration Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/menuable-trait.md Register your models with the Menuable trait in the configuration file to make them available for selection in Filament menu item forms. ```php return [ 'models' => [ 'Product' => \App\Models\Product::class, 'Category' => \App\Models\Category::class, ], ]; ``` -------------------------------- ### Extend Menu Resource Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/customization.md Create a custom Menu resource by extending the base `MenuResource` and overriding methods like `getModelLabel` and `getPluralModelLabel`. ```php ``` -------------------------------- ### Specify Custom Menu Resources Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/customization.md In your AdminPanelProvider.php, use `usingMenuResource` and `usingMenuItemResource` to specify custom resource classes. ```php use App\CustomClasses\MenuResource; use App\CustomClasses\MenuItemResource; public function panel(Panel $panel): Panel { return $panel // ... other configurations ->plugins([ \Biostate\FilamentMenuBuilder\FilamentMenuBuilderPlugin::make() ->usingMenuResource(MenuResource::class) ->usingMenuItemResource(MenuItemResource::class), ]); } ``` -------------------------------- ### Register Filament Menu Builder Plugin Source: https://github.com/biostate/filament-menu-builder/blob/main/README.md Add the FilamentMenuBuilderPlugin to your AdminPanelServiceProvider to enable the menu builder functionality. ```php public function panel(Panel $panel): Panel { return $panel ->plugins([ \Biostate\FilamentMenuBuilder\FilamentMenuBuilderPlugin::make(), ]); } ``` -------------------------------- ### Extend MenuItem Resource Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/customization.md Create a custom MenuItem resource by extending the base `MenuItemResource` and overriding methods like `getModelLabel` and `getPluralModelLabel`. ```php plugins([ \Biostate\FilamentMenuBuilder\FilamentMenuBuilderPlugin::make() ->usingMenuModel(CustomMenu::class) ->usingMenuItemModel(CustomMenuItem::class), ]); } ``` -------------------------------- ### Include Package Views in Custom Theme Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/installation.md Add this CSS rule to your custom theme's `theme.css` file to include the package's views. Ensure you run `npm run build` afterwards. ```css @source '../../../../vendor/biostate/filament-menu-builder/resources/views/**/*'; ``` -------------------------------- ### Restore Menu Item Label Behavior (Upgrade <5.0.2) Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/menuable-trait.md If you previously used getFilamentSearchLabel for display and are upgrading from <5.0.2, implement getMenuNameAttribute to ensure menu item labels are displayed correctly. ```php public function getMenuNameAttribute(): string { return (string) ($this->title ?? ''); } ``` -------------------------------- ### Create Hotfix Branch Source: https://github.com/biostate/filament-menu-builder/blob/main/RELEASING.md Branch off the latest tag to create a hotfix branch for addressing critical issues in production. ```bash git checkout -b hotfix/foo vX.Y.Z ``` -------------------------------- ### Handle Null Name Column (Upgrade <5.0.4) Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/menuable-trait.md For models without a 'name' column, this ensures getMenuNameAttribute returns an empty string instead of throwing a TypeError, as per changes in version <5.0.4. ```php public function getMenuNameAttribute(): string { return (string) ($this->name ?? ''); } ``` -------------------------------- ### Add Plugin to Filament Panel Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/installation.md Register the FilamentMenuBuilderPlugin in your AdminPanelServiceProvider.php to enable the package's functionality. ```php public function panel(Panel $panel): Panel { return $panel // Your other configurations ->plugins([ \Biostate\FilamentMenuBuilder\FilamentMenuBuilderPlugin::make(), // Add this line ]); } ``` -------------------------------- ### Implement Menuable Trait in Model Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/menuable-trait.md Add the Menuable trait to your model and implement the getMenuLinkAttribute method to define the URL for menu items linked to this model. ```php use Biostate\FilamentMenuBuilder\Traits\Menuable; class Product extends Model { use Menuable; public function getMenuLinkAttribute(): string { return route('products.show', $this); } } ``` -------------------------------- ### Commit CHANGELOG Update Source: https://github.com/biostate/filament-menu-builder/blob/main/RELEASING.md Commit the changes made to the CHANGELOG.md file after updating it for a new release. ```bash git commit -m "Update CHANGELOG for vX.Y.Z" git push origin main ``` -------------------------------- ### Configure Custom Route Exclusion Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/routes.md Add custom regular expression patterns to the `exclude_route_names` array in your config file to prevent specific routes from appearing in menu items. This allows for flexible matching rules. ```php return [ 'exclude_route_names' => [ '/^debugbarelum/', // Exclude debugbar routes '/^filamentelum/', // Exclude filament routes '/^livewireelum/', // Exclude livewire routes '/^apielum/', // Exclude API routes '/^adminelum/', // Exclude admin routes ], ]; ``` -------------------------------- ### Customize Search Column for Menu Items Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/menuable-trait.md Customize the database column used for searching models in the menu item form by overriding the static getFilamentSearchLabel method. This method specifies the column for the LIKE query. ```php use Biostate\FilamentMenuBuilder\Traits\Menuable; class Page extends Model { use Menuable; public function getMenuLinkAttribute(): string { return route('pages.show', $this); } public function getMenuNameAttribute(): string { return $this->title; } public static function getFilamentSearchLabel(): string { return 'title'; } } ``` -------------------------------- ### Use Model Name as Menu Item Name Source: https://github.com/biostate/filament-menu-builder/blob/main/docs/menuable-trait.md Override the getMenuNameAttribute method to use a specific model attribute (e.g., 'name') as the display name for menu items. ```php use Biostate\FilamentMenuBuilder\Traits\Menuable; class Product extends Model { use Menuable; public function getMenuLinkAttribute(): string { return route('products.show', $this); } public function getMenuNameAttribute(): string { return $this->name; } } ``` -------------------------------- ### Merge Contributor PR with Merge Commit Source: https://github.com/biostate/filament-menu-builder/blob/main/RELEASING.md Merge a contributor's pull request using a merge commit and delete the branch afterwards. This preserves individual contributor history. ```bash gh pr merge --merge --delete-branch ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.