Build structured navigation menus in Filament.

Overview

Build structured navigation menus in Filament.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This plugin for Filament provides a Navigation resource that allows to build structural navigation menus with ease.

Installation

Begin by installing this package via Composer:

composer require ryangjchandler/filament-navigation

Publish the package's assets:

php artisan vendor:publish --tag="filament-navigation-assets"

Usage

The NavigationResource is automatically registered with Filament so no configuration is required to start using it.

If you wish to customise the navigation group, sort or icon, you can use the respective NavigationResource::navigationGroup(), NavigationResource::navigationSort() and NavigationResource::navigationIcon() methods.

Data structure

Each navigation menu is required to have a name and handle. The handle should be unique and used to retrieve the menu.

Items are stored inside of a JSON column called items. This is a recursive data structure that looks like:

[
    {
        "label": "Home",
        "type": "external-link",
        "data": {
            "url": "/",
            "target": "_blank",
        },
        "children": [
            // ...
        ],
    }
]

The recursive structure makes it really simple to render nested menus / dropdowns:

<ul>
    @foreach($menu->items as $item)
        <li>
            {{ $item['label'] }}

            @if($item['children'])
                <ul>
                    {{-- Render the item's children here... --}}
                </ul>
            @endforeach
        </li>
    @endforeach
</ul>

Retrieving a navigation object

To retreive a navigation object, provide the handle to the RyanChandler\FilamentNavigation\Facades\FilamentNavigation::get() method.

use RyanChandler\FilamentNavigation\Facades\FilamentNavigation;

$menu = FilamentNavigation::get('main-menu');

Custom item types

Out of the box, this plugin comes with a single "item type" called "External link". This item type expects a URL to be provided and an optional "target" (same tab or new tab).

It's possible to extend the plugin with custom item types. Custom item types have a name and an array of Filament field objects that will be displayed inside of the "Item" modal.

This API allows you to deeply integrate navigation menus with your application's own entities and models.

use RyanChandler\FilamentNavigation\Facades\FilamentNavigation;

FilamentNavigation::addItemType('Post link', [
    Select::make('post_id')
        ->searchable()
        ->options(function () {
            return Post::pluck('title', 'id');
        })
]);

All custom fields for the item type can be found inside of the data property on the item.

The Navigation field type

This plugin also provides a custom Filament field that can be used to search and select a navigation menu inside other forms and resources.

use RyanChandler\FilamentNavigation\Filament\Fields\NavigationSelect;

->schema([
    NavigationSelect::make('navigation_id'),
])

By default, this field will not be searchable and the value for each option will be the menu id.

To make the field searchable, call the ->searchable() method.

->schema([
    NavigationSelect::make('navigation_id')
        ->searchable(),
])

If you wish to change the value for each option, call the ->optionValue() method.

->schema([
    NavigationSelect::make('navigation_id')
        ->optionValue('handle'),
])

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
Releases(v0.4.2)
  • v0.4.2(Dec 8, 2022)

    What's Changed

    • Fixed navigation model class handling. by @danielbehrendt in https://github.com/ryangjchandler/filament-navigation/pull/56

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.4.1...v0.4.2

    Source code(tar.gz)
    Source code(zip)
  • v0.4.1(Nov 29, 2022)

    What's Changed

    • Fix typo in it translation by @digitall-it in https://github.com/ryangjchandler/filament-navigation/pull/55

    New Contributors

    • @digitall-it made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/55

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.4.0...v0.4.1

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Nov 17, 2022)

    What's Changed

    • Bump dependabot/fetch-metadata from 1.3.4 to 1.3.5 by @dependabot in https://github.com/ryangjchandler/filament-navigation/pull/49
    • Fix actions by @Kristories in https://github.com/ryangjchandler/filament-navigation/pull/48
    • feature: drag & drop navigation by @ryangjchandler in https://github.com/ryangjchandler/filament-navigation/pull/51
    • Enabled model and resource class configuration. by @danielbehrendt in https://github.com/ryangjchandler/filament-navigation/pull/53

    New Contributors

    • @Kristories made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/48
    • @danielbehrendt made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/53

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.3.2...v0.4.0

    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(Oct 27, 2022)

    What's Changed

    • Add german translations by @bumbummen99 in https://github.com/ryangjchandler/filament-navigation/pull/35
    • Bump dependabot/fetch-metadata from 1.3.3 to 1.3.4 by @dependabot in https://github.com/ryangjchandler/filament-navigation/pull/42
    • Added French translations by @FDT2k in https://github.com/ryangjchandler/filament-navigation/pull/47
    • Italian tranlation; fixed label 'Type' in modal by @mynamespace in https://github.com/ryangjchandler/filament-navigation/pull/46

    New Contributors

    • @FDT2k made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/47
    • @mynamespace made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/46

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.3.1...v0.3.2

    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Sep 11, 2022)

    What's Changed

    • [Fix] Load support ServiceProvider by @bumbummen99 in https://github.com/ryangjchandler/filament-navigation/pull/20
    • Fix typo in README by @happytodev in https://github.com/ryangjchandler/filament-navigation/pull/28
    • Bump dependabot/fetch-metadata from 1.3.1 to 1.3.3 by @dependabot in https://github.com/ryangjchandler/filament-navigation/pull/30
    • A Minor updated on the README to reflect need to Run Migration by @blackmunk in https://github.com/ryangjchandler/filament-navigation/pull/32
    • Created translations for plugin by @koupisbean in https://github.com/ryangjchandler/filament-navigation/pull/25
    • [feat] Add pt_BR and pt_PT translations by @devmatheus in https://github.com/ryangjchandler/filament-navigation/pull/36

    New Contributors

    • @bumbummen99 made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/20
    • @happytodev made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/28
    • @blackmunk made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/32
    • @koupisbean made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/25
    • @devmatheus made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/36

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.3.0...v0.3.1

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jun 16, 2022)

    What's Changed

    • fix: entangle-based components not working in item modal by @ryangjchandler in https://github.com/ryangjchandler/filament-navigation/pull/18

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.2.4...v0.3.0

    Source code(tar.gz)
    Source code(zip)
  • v0.2.4(Jun 13, 2022)

    What's Changed

    • Add type hint for property by @flxsource in https://github.com/ryangjchandler/filament-navigation/pull/16

    New Contributors

    • @flxsource made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/16

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.2.3...v0.2.4

    Source code(tar.gz)
    Source code(zip)
  • v0.2.3(May 5, 2022)

    What's Changed

    • Avoid overlapping of tooltips by @justRau in https://github.com/ryangjchandler/filament-navigation/pull/11

    New Contributors

    • @justRau made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/11

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.2.2...v0.2.3

    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Apr 25, 2022)

    What's Changed

    • Bump dependabot/fetch-metadata from 1.3.0 to 1.3.1 by @dependabot in https://github.com/ryangjchandler/filament-navigation/pull/10
    • [FIX] showing the navigation_type name by @lordjoo in https://github.com/ryangjchandler/filament-navigation/pull/6

    New Contributors

    • @dependabot made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/10
    • @lordjoo made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/6

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.2.1...v0.2.2

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Apr 21, 2022)

    What's Changed

    • Fixes Tailwind config to use class based dark mode. by @awcodes in https://github.com/ryangjchandler/filament-navigation/pull/5

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.2.0...v0.2.1

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Apr 21, 2022)

    What's Changed

    • fix: use longText instead of json column for MySQL 5.7 by @ryangjchandler in https://github.com/ryangjchandler/filament-navigation/pull/4
    • Fixes item input styling for dark mode. by @awcodes in https://github.com/ryangjchandler/filament-navigation/pull/2

    Upgrade

    When upgrading to this version, please run the following commands:

    composer update
    php artisan view:clear
    php artisan vendor:publish --tag="filament-navigation-assets"
    php artisan migrate
    

    New Contributors

    • @ryangjchandler made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/4
    • @awcodes made their first contribution in https://github.com/ryangjchandler/filament-navigation/pull/2

    Full Changelog: https://github.com/ryangjchandler/filament-navigation/compare/v0.1.0...v0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Apr 19, 2022)

Owner
Ryan Chandler
Ryan Chandler
Navigator is a package to create headless navigation menus for use in Laravel applications

Navigator Navigator is a package to create headless navigation menus for use in Laravel applications: // In a Service Provider Nav::define(fn ($user)

Sam Rowden 36 Oct 30, 2022
Build XML based USSD menus.

Instead of having tonnes of nested, complex PHP files, this package give you the ability to construct your menus in XML and execute them as though they were plain PHP files.

Brian Matovu 6 Oct 6, 2022
Filament-spatie-laravel-activitylog - View your activity logs inside of Filament. ⚡️

View your activity logs inside of Filament. This package provides a Filament resource that shows you all of the activity logs created using the spatie

Ryan Chandler 45 Dec 26, 2022
Fullstack komponents to write Forms, Queries and Menus in Laravel

kompo.io • Documentation • Demos • Twitter kompo/kompo kompo/kompo is a library of Fullstack Komponents to help you write forms, queries and menus in

Bass El Hachem 107 Dec 5, 2022
A demo of how to use filament/forms to build a user-facing Form Builder which stores fields in JSON.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Dan Harrin 41 Dec 24, 2022
Hoa is a modular, extensible and structured set of PHP libraries

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds. Hoa\Rul

Hoa 624 Dec 30, 2022
This package aims to help you standardize all your API responses in a simple and structured way.

Laravel API Response This package aims to help you standardize all your API responses in a simple and structured way. By default, the stucture of the

Kode Pandai 6 Dec 6, 2022
Framework agnostic PHP package for marking navigation items active.

Ekko Framework agnostic PHP package for marking navigation items active. Features Framework agnostic. Can be modified for any custom application and U

Laravelista 275 Jul 27, 2022
A mostly useless package to display framework versions at the bottom of the Admin navigation panel.

A mostly useless package to display framework versions at the bottom of the Filament Admin navigation panel and an optional widget to do the same in the dashboard or custom pages.

Adam Weston 10 Nov 8, 2022
A simple profile management page for Filament. ✨

A simple profile page for Filament. This package provides a very simple Profile page that allows the current user to manage their name, email address

Ryan Chandler 65 Jan 5, 2023
Add a general-purpose tools page to your Filament project. 🛠

Add a general-purpose tools page to your Filament project. Installation You can install the package via Composer: composer require ryangjchandler/fila

Ryan Chandler 24 Dec 6, 2022
The Most Popular JavaScript Calendar as a Filament Widget 💛

The Most Popular JavaScript Calendar as a Filament Widget ?? Features Accepts all configurations from FullCalendar Event click and drop events Upcomin

Guilherme Saade 62 Dec 31, 2022
A single-field repeater for Filament. ⚡️

A single-field repeater for Filament. This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. Insta

Ryan Chandler 3 Mar 5, 2022
A convenient helper for using the laravel-seo package with Filament Admin and Forms

Combine the power of Laravel SEO and Filament PHP. This package is a convenient helper for using the laravel-seo package with Filament Admin and Forms

Ralph J. Smit 39 Dec 21, 2022
Easily interact and control your feature flags from Filament

Easily interact and control your feature flags from Filament

Ryan Chandler 32 Nov 29, 2022
Admin user, role and permission management for Laravel Filament

Filament Access Control Opinionated setup for managing admin users, roles and permissions within Laravel Filament Features Separate database table for

Elisha Witte 69 Jan 4, 2023
Access laravel log through Filament admin panel

Access laravel log through Filament admin panel Features Syntax highlighting Quickly jump between start and end of the file Refresh log contents Clear

Guilherme Saade 20 Nov 22, 2022
A collection of reusable components for Filament.

A collection of reusable components for Filament. This package is a collection of handy components for you to use in all your Filament projects. It pr

Ralph J. Smit 35 Nov 16, 2022
Social login for Filament through Laravel Socialite

Social login for Filament through Laravel Socialite Add OAuth login through Laravel Socialite to Filament. Installation You can install the package vi

Dutch Coding Company 44 Dec 26, 2022