Giter VIP home page Giter VIP logo

Comments (2)

sebastienheyd avatar sebastienheyd commented on May 22, 2024

Hello,

There is not a single place to edit the whole menu. I chose to split the menu into several files so that I could provide them in other packages.

For exemple, to add new menu items I create a new folder app/Menu. Into this folder i put classes to add menu items, for exemple Shops.php (see the comments) :

<?php

namespace App\Menu;

use Sebastienheyd\Boilerplate\Menu\Builder;

class Shops
{
    public function make(Builder $menu)
    {
        // You must have a route with the alias shops.index
        // See font-awesome for icons, here fa-shopping-cart
        $menu->add('Shops', [ 'route' => 'shops.index', 'icon' => 'shopping-cart' ])
            ->id('shops')      // Menu item ID
            ->order(100)     // This will manage the menu item "weight" to define his position
            ->activeIfRoute('shops.*');  // To set "active" css class on the menu item for all pages with route beginning with "shops."
    }
}

After that, you need to declare it into config/boilerplate/menu.php :

<?php

/**
 * Define here every class you want to call to build the backend menu
 * Every class need a method make(Builder $menu)
 *
 * @see \Sebastienheyd\Boilerplate\ViewComposers\MenuComposer
 */

return [
    'providers' => [
        \Sebastienheyd\Boilerplate\Menu\Users::class,
        \Sebastienheyd\Boilerplate\Menu\Logs::class,
        \App\Menu\Shops::class,
    ]
];

By doing this, you can deliver the file in a package and for example install it by making a vendor:publish . The only condition is that you must add the line into config/boilerplate/menu.php (I'm thinking on how i can do it magically).

You can watch in Users.php for adding sub items.

Permissions are linked to scripts, views, routes, ... this is why I use migrations and i'm not allowing to create them by a form... for this moment... ;)

from boilerplate.

verygod avatar verygod commented on May 22, 2024

Perfect! Got it this time! Menu is up and running now, will wait for the permissions update. The option to CRUD the permission would be cool, the whole back-end stuff could be taken care of by the dev himself. Atleast when I search for something like you did was simple. Easy code (which most of the part is in your code) and the CRUD options for user / role / permission managment. I can code everything else myself just the forms take way longer than I want to. :D

Thanks for the explanation. :)

from boilerplate.

Related Issues (20)

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.