Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msurguy/laravel-shop-menu
Menu ordering/management application demo, like Wordpress menu manager
https://github.com/msurguy/laravel-shop-menu
Last synced: about 2 months ago
JSON representation
Menu ordering/management application demo, like Wordpress menu manager
- Host: GitHub
- URL: https://github.com/msurguy/laravel-shop-menu
- Owner: msurguy
- Archived: true
- Created: 2014-01-16T01:27:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-01-16T08:38:19.000Z (over 10 years ago)
- Last Synced: 2024-07-13T10:35:52.737Z (2 months ago)
- Language: PHP
- Homepage: http://laravel-menu-builder.gopagoda.com/admin/menu
- Size: 683 KB
- Stars: 337
- Watchers: 19
- Forks: 100
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Menu manager like Wordpress using Laravel and Nestable
See demo at: http://laravel-menu-builder.gopagoda.com/admin/menu
Tutorial coming up at: http://maxoffsky.comThis application demonstrates usage of [Nestable plugin](https://github.com/dbushell/Nestable) jQuery plugin to provide the user with nice menu ordering experience without a page refresh:
![menu ordering in action](https://raw.github.com/msurguy/laravel-shop-menu/master/menumanager.gif)The menu controller is in app/controllers/Admin/MenuController.php
The menu model is in app/models/Menu.php### A note on the data structure for the menu
The important columns of the "menus" table are:
- id
- parent_id
- orderWith these 3 fields we can build nested menus as many levels deep as you want.
The Nestable plugin helps modify the values of these fields for the appropriate rows of data.### Use of recursion
The hard part that took me a looong time to build is a very small function inside of app/models/Menu.php:
```
public function buildMenu($menu, $parentid = 0)
{
$result = null;
foreach ($menu as $item)
if ($item->parent_id == $parentid) {
$result .= "
".$this->buildMenu($menu, $item->id) . "
}
return $result ? "\n
- \n$result
}
```
This function uses recursion to display the menu to the user even if the menu is many many levels deep. This function alone can save you a bunch of time.
### Installation instructions:
- Download this repo
- Set up a MySQL DB named 'shop-menu' and import install.sql file into it, make sure you edit credentials in app/config/database.php to match yours
- Open up terminal and CD into the folder of this repo
- Run "php artisan serve" to run the application
- Open up the browser and navigate to "localhost:8000" to see it in action
### Star this repo!
The more people star my repos - the more I will give back to the community.
### Read more on my blog and follow on Twitter
I post tutorials all the time on my blog : http://maxoffsky.com, stay updated on my Twitter: http://twitter.com/msurguy
### License
The Laravel menu manager is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)