Code Monkey home page Code Monkey logo

laravel-nova-menu's Introduction

Nova menu manager

Travis Packagist Release Licence

A Nova tool to manage menus.

Requirements

  • PHP >= 7.2
  • Laravel Nova >= 2.0
  • Laravel Framework >= 6.0

NOTE: These instructions are for Laravel 6.0. If you are using Laravel 5.8, please see the previous version's docs.

Installation

composer require novius/laravel-nova-menu

Then, launch migrations

php artisan migrate

Configuration

Some options that you can override are available.

php artisan vendor:publish --provider="Novius\LaravelNovaMenu\LaravelNovaMenuServiceProvider" --tag="config"

Edit default templates

Run:

php artisan vendor:publish --provider="Novius\LaravelNovaMenu\LaravelNovaMenuServiceProvider" --tag="views"

Usage

Blade directive

You can display menu with :

@menu("slug-of-menu")

Override views

You can override views with :

php artisan vendor:publish --provider="Novius\LaravelNovaMenu\LaravelNovaMenuServiceProvider" --tag="views"

Manage internal link possibilities

linkable_objects

You can add dynamic routes to linkable_objects array (in configuration file).

Example with App\Models\Foo Model.

In this example we have a route defined as following :

Route::get('foo/{slug}', 'FooController@show')->name('foo.show');

First, you have to add the Model to laravel-nova-menu.php config file.

return [
    'linkable_objects'=> [
        App\Models\Foo:class => 'foo.label', // foo.label is a translation key
    ],
    ...
];

Then, you have to implements Linkable trait to the model.

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Novius\LaravelNovaMenu\Traits\Linkable;

class Foo extends Model
{
    use Linkable;

    public function linkableUrl(): string
    {
        return route('foo.show', ['slug' => $this->slug]);
    }

    public function linkableTitle(): string
    {
        return $this->name;
    }
}

linkable_routes

You can also add static routes to linkable_routes array (in configuration file).

Example with a route with name home.

return [
    'linkable_objects'=> [
        'contact' => 'contact.page', // contact.page is a translation key
    ],
    ...
];

Lint

Run php-cs with:

composer run-script lint

Contributing

Contributions are welcome! Leave an issue on Github, or create a Pull Request.

Licence

This package is under GNU Affero General Public License v3 or (at your option) any later version.

laravel-nova-menu's People

Contributors

alicecd avatar domasweb avatar tonyyb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.