Giter VIP home page Giter VIP logo

laravel-backpack-menu's Introduction

Laravel Backoffice Menu

Travis Packagist Release Licence

Manages the editing and rendering of menus in a Laravel - Backpack application.

Installation

In your terminal:

composer require novius/laravel-backpack-menu

Then, if you are on Laravel 5.4 (no need for Laravel 5.5 and higher), register the service provider to your config/app.php file:

Novius\Backpack\Menu\MenuServiceProvider::class

Finally, run:

php artisan vendor:publish --provider="Novius\Backpack\Menu\MenuServiceProvider" --tag="routes"
php artisan vendor:publish --provider="Novius\Backpack\Menu\MenuServiceProvider" --tag="lang"
php artisan vendor:publish --provider="Novius\Backpack\Menu\MenuServiceProvider" --tag="migrations"
php artisan vendor:publish --provider="Novius\Backpack\Menu\MenuServiceProvider" --tag="views"
php artisan vendor:publish --provider="Novius\Backpack\Menu\MenuServiceProvider" --tag="config"

php artisan migrate

Usage & Features

You can display the menu within your view like this:

// The function takes two parameters:
//  1. Slug => Identifies the menu
//  2. Locale => (Optional) Force a locale version of the menu.

\Novius\Backpack\Menu\Models\Menu::display('header', 'en');

To achieve that, first you need:

Configure the package. Take a look at the comments in:

/config/laravel-backpack-menu.php

Use the trait LinkedItems in the models you listed in the linkableObjects configuration

use Novius\Backpack\Menu\LinkedItems;

// And optionally overrides the base functionality to suit your needs:

public static function linkableItems(string $prefix = ''): array
public static function linkableRoute(string $routeName, string $translation): array
public function linkableUrl(): string
public function linkableTitle(): string
public function linkableId(): string

Add a link in your sidebar.blade.php file to get access from the backpack backoffice

<li>
  <a href="{{ route('crud.menu.index') }}">
      <i class="fa fa-list"></i>
      <span>{{ trans('laravel-backpack-menu::menu.menus') }}</span>
  </a>
</li>

Create your menus and items. You can reorder and nest the items. The items are related to the current locale. Switch the back-office language to add items for other locales.

Testing

Run the tests with:

./test.sh

Any modification must pass all the tests. Any modification should be covered by a test.

Lint

Run php-cs with:

./cs.sh

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-backpack-menu's People

Contributors

jguyomard avatar shaoshiva avatar tonyyb avatar

Watchers

James Cloos 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.