DEV Community

begicf
begicf

Posted on

Simple Laravel package, creating menus from DB sources.

By creating any project, we face the problem of creating a menu.

Often, we need a simple menu that can be updated at the DB layer, because of that I created a very simple package for Laravel.

This package is customized for bootstrap 4.*, but you can change the view for other or custom css libraries.

Install

composer require begicf/simple-menu
Enter fullscreen mode Exit fullscreen mode

Register Service Provider

Go in 'config/app.php' file.

Find array providers and add this element to register provider:

\SimpleMenu\SimpleMenuServiceProvider::class
Enter fullscreen mode Exit fullscreen mode

Migrate

php artisan migrate
Enter fullscreen mode Exit fullscreen mode

SQL Menu table

Name Type
id int
parent_id int
title varchar (255)
description varchar (255)
order int
created_at timestamp
update_at timestamp

How to use

Put in view blade template

<x-menu-menu-component />
Enter fullscreen mode Exit fullscreen mode

Publish resources

php artisan vendor:publish --provider="SimpleMenu\SimpleMenuServiceProvider"

Enter fullscreen mode Exit fullscreen mode

Example

<ul class="navbar-nav mr-auto">
  <x-menu-menu-component />
</ul>
Enter fullscreen mode Exit fullscreen mode
Image 1

Image2

Image 2

Image1

Top comments (1)

Collapse
 
mdoleire_62 profile image
mdoleire

Hi, does it work with laravel 8?