Skip to content

Commit 7a25455

Browse files
committed
Initialize first release
1 parent bd2a715 commit 7a25455

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+98739
-2
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.php linguist-language=PHP
2+
*.js linguist-language=PHP

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
# laravel-menu-builder
2-
Laravel Drag and Drop Menu Builder
1+
# Laravel Menu Builder
2+
Laravel Menu Builder with VueJs and jQuery.
3+
4+
#Install the Package
5+
6+
```
7+
composer require codexshaper/laravel-menu-builder
8+
```
9+
#Publish Resource, Configs, Migration and Seeding Database in a single command
10+
11+
```
12+
php artisan menu:install
13+
```
14+
#run `php artisan serve`
15+
16+
#for check menus go to `http://127.0.0.1:8000/admin/menus` . You can change `admin` prefix from `config/menu.php`
17+
18+
#How to use Menu in your site?
19+
1. Call Menu anywhere on your site by calling `{{ menu('name') }}` or `@menu('name')`
20+
2. Link CSS and JS if you want to use our default design
21+
```
22+
CSS: <link rel="stylesheet" type="text/css" href="{{ menu_asset('css/menu.css') }}">
23+
JS: <script src="{{ menu_asset('js/menu.js') }}"></script>
24+
```
25+
3. Optional: If you don't have jQuery and bootstrap in your page then add bellow files before above CSS and Js
26+
```
27+
CSS: <link rel="stylesheet" type="text/css" href="{{ menu_asset('css/app.css') }}">
28+
JS: <script src="{{ menu_asset('js/menu.js') }}"></script>
29+
```

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "codexshaper/laravel-menu-builder",
3+
"description": "Laravel Drag and Drop Menu Builder",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Md Abu Ahsan Basir",
9+
"email": "maab.career@gmail.com"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"require": {},
14+
"autoload": {
15+
"psr-4": {
16+
"CodexShaper\\Menu\\": "src/"
17+
}
18+
},
19+
"extra": {
20+
"laravel": {
21+
"providers": [
22+
"CodexShaper\\Menu\\MenuServiceProvider"
23+
],
24+
"aliases": {
25+
"MenuBuilder": "CodexShaper\\Menu\\Facades\\Menu"
26+
}
27+
}
28+
}
29+
}

config/menu.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
return [
3+
'prefix' => '/admin',
4+
'namespace' => '\CodexShaper\Menu',
5+
'controller_namespace' => '\CodexShaper\Menu\Http\Controllers',
6+
'resources_path' => 'vendor/codexshaper/laravel-menu-builder/publishable/assets/',
7+
'views' => 'vendor/codexshaper/laravel-menu-builder/publishable/views',
8+
// Menu Settings
9+
'depth' => 5,
10+
'apply_child_as_parent' => false,
11+
'levels' => [
12+
'root' => [
13+
'style' => 'vertical', // horizontal | vertical
14+
],
15+
'child' => [
16+
'show' => 'onClick', // onclick | onHover
17+
'level_1' => [
18+
'show' => 'onClick',
19+
'position' => 'bottom',
20+
],
21+
'level_2' => [
22+
'show' => 'onHover',
23+
'position' => 'right',
24+
],
25+
],
26+
],
27+
];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateMenusTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('menus', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->string('name');
19+
$table->string('slug');
20+
$table->string('url')->nullable();
21+
$table->integer('order')->unsigned()->default(0);
22+
$table->string('custom_class')->nullable();
23+
$table->timestamps();
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down()
33+
{
34+
Schema::dropIfExists('menus');
35+
}
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateMenuItemsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('menu_items', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('menu_id');
19+
$table->string('title');
20+
$table->string('slug');
21+
$table->string('url')->nullable();
22+
$table->string('target')->default('_self');
23+
$table->integer('parent_id')->unsigned()->nullable();
24+
$table->integer('order')->unsigned()->default(0);
25+
$table->string('icon')->nullable();
26+
$table->string('custom_class')->nullable();
27+
$table->timestamps();
28+
});
29+
}
30+
31+
/**
32+
* Reverse the migrations.
33+
*
34+
* @return void
35+
*/
36+
public function down()
37+
{
38+
Schema::dropIfExists('menu_items');
39+
}
40+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateMenuSettingsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('menu_settings', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('menu_id')->nullable();
19+
$table->string('depth')->default(5);
20+
$table->boolean('applyChildAsParent')->default(false);
21+
$table->text('levels')->nullable();
22+
$table->timestamps();
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
Schema::dropIfExists('menu_items');
34+
}
35+
}

database/seeds/MenuDatabaseSeeder.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Illuminate\Database\Seeder;
4+
5+
class MenuDatabaseSeeder extends Seeder
6+
{
7+
protected $seedersPath = __DIR__ . '/../../database/seeds/';
8+
/**
9+
* Seed the application's database.
10+
*
11+
* @return void
12+
*/
13+
public function run()
14+
{
15+
$seeds = [
16+
'MenuItemsSeeder',
17+
'MenuSettingsSeeder',
18+
];
19+
20+
foreach ($seeds as $class) {
21+
22+
$file = $this->seedersPath . $class . '.php';
23+
if (file_exists($file) && !class_exists($class)) {
24+
require_once $file;
25+
}
26+
with(new $class())->run();
27+
}
28+
}
29+
}

database/seeds/MenuItemsSeeder.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use CodexShaper\Menu\Models\Menu;
4+
use CodexShaper\Menu\Models\MenuItem;
5+
use Illuminate\Database\Seeder;
6+
use Illuminate\Support\Str;
7+
8+
class MenuItemsSeeder extends Seeder
9+
{
10+
/**
11+
* Run the database seeds.
12+
*
13+
* @return void
14+
*/
15+
public function run()
16+
{
17+
$menu = new Menu;
18+
$menu->name = "Admin";
19+
$menu->slug = Str::slug('Admin');
20+
$menu->url = '/admin';
21+
$menu->order = 1;
22+
$menu->save();
23+
24+
$menuItem = new MenuItem;
25+
$menuItem->menu_id = $menu->id;
26+
$menuItem->title = "Menu Builder";
27+
$menuItem->slug = Str::slug("Menu Builder");
28+
$menuItem->url = "/admin/menu/menu-builder";
29+
$menuItem->parent_id = null;
30+
$menuItem->order = 1;
31+
$menuItem->target = '_self';
32+
$menuItem->icon = null;
33+
$menuItem->custom_class = null;
34+
$menuItem->save();
35+
}
36+
}

database/seeds/MenuSettingsSeeder.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
use CodexShaper\Menu\Models\MenuSetting;
4+
use Illuminate\Database\Seeder;
5+
6+
class MenuSettingsSeeder extends Seeder
7+
{
8+
/**
9+
* Run the database seeds.
10+
*
11+
* @return void
12+
*/
13+
public function run()
14+
{
15+
$settings = new MenuSetting;
16+
$settings->menu_id = null;
17+
$settings->depth = 5;
18+
$settings->applyChildAsParent = 0;
19+
$settings->levels = [
20+
'root' => [
21+
'style' => 'vertical', // horizontal | vertical
22+
],
23+
'child' => [
24+
'show' => 'onClick', // onclick | onHover
25+
'position' => 'right',
26+
'level_1' => [
27+
'show' => 'onClick',
28+
'position' => 'bottom',
29+
],
30+
'level_2' => [
31+
'show' => 'onHover',
32+
'position' => 'right',
33+
],
34+
],
35+
];
36+
$settings->save();
37+
}
38+
}

0 commit comments

Comments
 (0)