Giter Site home page Giter Site logo

wmenu-builder's Introduction

Laravel Drag and Drop menu editor like wordpress

*This package is abandoned: I'm not maintaining this package anymore, please contact me if you want to take over this project or feel free to fork and make your own. Thank you

Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads

forked from https://github.com/lordmacu/wmenu Laravel drag and drop menu

Installation

  1. Run
composer require harimayco/laravel-menu

Step 2 & 3 are optional if you are using laravel 5.5

  1. Add the following class, to "providers" array in the file config/app.php (optional on laravel 5.5)
Harimayco\Menu\MenuServiceProvider::class,
  1. add facade in the file config/app.php (optional on laravel 5.5)
'Menu' => Harimayco\Menu\Facades\Menu::class,
  1. Run publish
php artisan vendor:publish --provider="Harimayco\Menu\MenuServiceProvider"
  1. Configure (optional) in config/menu.php :
  • CUSTOM MIDDLEWARE: You can add you own middleware
  • TABLE PREFIX: By default this package will create 2 new tables named "menus" and "menu_items" but you can still add your own table prefix avoiding conflict with existing table
  • TABLE NAMES If you want use specific name of tables you have to modify that and the migrations
  • Custom routes If you want to edit the route path you can edit the field
  • Role Access If you want to enable roles (permissions) on menu items
  1. Run migrate
php artisan migrate

DONE

Menu Builder Usage Example - displays the builder

On your view blade file

@extends('app')

@section('contents')
    {!! Menu::render() !!}
@endsection

//YOU MUST HAVE JQUERY LOADED BEFORE menu scripts
@push('scripts')
    {!! Menu::scripts() !!}
@endpush

Using The Model

Call the model class

use Harimayco\Menu\Models\Menus;
use Harimayco\Menu\Models\MenuItems;

Menu Usage Example (a)

A basic two-level menu can be displayed in your blade template

Using Model Class
/* get menu by id*/
$menu = Menus::find(1);
/* or by name */
$menu = Menus::where('name','Test Menu')->first();

/* or get menu by name and the items with EAGER LOADING (RECOMENDED for better performance and less query call)*/
$menu = Menus::where('name','Test Menu')->with('items')->first();
/*or by id */
$menu = Menus::where('id', 1)->with('items')->first();

//you can access by model result
$public_menu = $menu->items;

//or you can convert it to array
$public_menu = $menu->items->toArray();
or Using helper
// Using Helper 
$public_menu = Menu::getByName('Public'); //return array

Menu Usage Example (b)

Now inside your blade template file place the menu using this simple example

<div class="nav-wrap">
    <div class="btn-menu">
        <span></span>
    </div><!-- //mobile menu button -->
    <nav id="mainnav" class="mainnav">

        @if($public_menu)
        <ul class="menu">
            @foreach($public_menu as $menu)
            <li class="">
                <a href="{{ $menu['link'] }}" title="">{{ $menu['label'] }}</a>
                @if( $menu['child'] )
                <ul class="sub-menu">
                    @foreach( $menu['child'] as $child )
                        <li class=""><a href="{{ $child['link'] }}" title="">{{ $child['label'] }}</a></li>
                    @endforeach
                </ul><!-- /.sub-menu -->
                @endif
            </li>
            @endforeach
        @endif

        </ul><!-- /.menu -->
    </nav><!-- /#mainnav -->
 </div><!-- /.nav-wrap -->

HELPERS

Get Menu Items By Menu ID

use Harimayco\Menu\Facades\Menu;
...
/*
Parameter: Menu ID
Return: Array
*/
$menuList = Menu::get(1);

Get Menu Items By Menu Name

In this example, you must have a menu named Admin

use Harimayco\Menu\Facades\Menu;
...
/*
Parameter: Menu ID
Return: Array
*/
$menuList = Menu::getByName('Admin');

Customization

you can edit the menu interface in resources/views/vendor/wmenu/menu-html.blade.php

Credits

  • wmenu laravel package menu like wordpress

Compatibility

  • Tested with laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6.x, 7.x

KNOWN ISSUES

  • Not working with RTL websites #21 (pull requests are welcome)

wmenu-builder's People

Contributors

buzzclue avatar deep2065 avatar developeroncall avatar ezequiel9 avatar harimayco avatar konmavrakis avatar lordmacu avatar lordmacus avatar monwolf avatar nauvalazhar avatar odhier avatar sadiqultra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wmenu-builder's Issues

Undefined variable: public_menu

[SOLVED] I successfully display the builder, now I am trying to show menu in front page, but it show me Undefined variable: public_menu. Can you tell me why?

Made it working on laravel 5.8

Laravel 5.8
php 7.2

I Got this error when i choose menu to edit, i don't know why, but when i change {!! !!} to {{..}} i got htmlspecialcharacter() error.
if any one know how to fix this
Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Undefined property: stdClass::$title (View: D:\WorkSpace\Rim Academy\Designs\RimAcademy\resources\views\vendor\harimayco-menu\menu-html.blade.php)"

Drag and Drop in mobile

Hi,
I want to edit menu items in my mobile. Please allow support in touch screen too.
Thanks you.

Parenting doesn't work

Hello, I'm using laravel-menu with Laravel 5.8 and it looks like the parent is never used.
Whether in the display or in the ajax query.

image

Plus some styles are totally fucked up

image

Please can you help me ?

Problem with RTL

Hi
I have problem with RTL website. subelements not working in RTL. Is there any solution?

{!! Menu::scripts() !!} Not Working

So, this is my web.php:
Route::group(['middleware' => config('menu.middleware')], function () { Route::get('wmenuindex', array('as' => 'menus.index', 'uses'=>'MenuController@index')); $path = rtrim(config('menu.route_path')); Route::post($path . '/addcustommenu', array('as' => 'haddcustommenu', 'uses' => 'MenuController@addcustommenu')); Route::post($path . '/deleteitemmenu', array('as' => 'hdeleteitemmenu', 'uses' => 'MenuController@deleteitemmenu')); Route::post($path . '/deletemenug', array('as' => 'hdeletemenug', 'uses' => 'MenuController@deletemenug')); Route::post($path . '/createnewmenu', array('as' => 'hcreatenewmenu', 'uses' => 'MenuController@createnewmenu')); Route::post($path . '/generatemenucontrol', array('as' => 'hgeneratemenucontrol', 'uses' => 'MenuController@generatemenucontrol')); Route::post($path . '/updateitem', array('as' => 'hupdateitem', 'uses' => 'MenuController@updateitem')); });

and this is a view:
`@extends("layouts.app")

@section("title") Users list @endsection

@section('index-admin-list')
{{ Breadcrumbs::render('list-active-admin') }}
@endsection

@section("content")

@if(session('status'))

{{session('status')}}
@endif

{!! Menu::render() !!}
@endsection

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

@Push('scripts')
{!! Menu::scripts() !!}
@endpush`

And in controller I use this code:
https://github.com/harimayco/wmenu-builder/blob/master/src/Controllers/MenuController.php

But the problem I can't create a new menu. Am I missing something?

Jquery Problem

Where I Place Jquery . Please Guide B/c Project is not working
I have place Jquery beforre menu js but it does'nt working

Support laravel 8

I tried to install it on laravel 8 but it gave the following error:

`
Problem 1

- Conclusion: don't install harimayco/laravel-menu 1.4.4

- Conclusion: don't install harimayco/laravel-menu 1.4.3

- Conclusion: don't install harimayco/laravel-menu 1.4.2

- Conclusion: don't install harimayco/laravel-menu 1.4.1

- Conclusion: remove laravel/framework v8.6.0

- Installation request for harimayco/laravel-menu ^1.4 -> satisfiable by harimayco/laravel-menu[1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4].

- Conclusion: don't install laravel/framework v8.6.0`

Don't load resources/views/vendor/harimayco-menu/menu-html.blade.php

When i run command: php artisan vendor:publish --provider="Harimayco\Menu\MenuServiceProvider" and try edit the menu interface in resources/views/vendor/harimayco-menu/menu-html.blade.php, but Package did not load to this file. There are no changes after editing

I use laravel 5.8 on Nginx

htmlspecialchars() expects parameter 1 to be string, array given [L5.6]

Trying to render my menu on a blade view file.

HomeController.php

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        /*
        Parameter: Menu ID
        Return: Array
        */
        $menuList = Menu::get(1);

        return view('home', compact('menuList'));
    }

home.blade.php

{{ $menuList }}

Error

htmlspecialchars() expects parameter 1 to be string, array given

Can't Add Class to Distinguish Between Single Menu and Menu Has Child

I am trying to add class drop-down if menu has child, but it can't.

@if($public_menu)


    @foreach($public_menu as $menu)
    @if( $menu['child'] )
    li class=" {{ ($menu['child']) ? 'drop-down' : '' }}">
    a href="{{ $menu['link'] }}" title="">{{ $menu['label'] }}

      @foreach( $menu['child'] as $child )
      li class="">a href="{{ $child['link'] }}" title="">{{ $child['label'] }}
      @Endforeach

    </l i>
    @endif
    @Endforeach

          @endif
    

    Any solution about this?

redirect to /home when adding custom Link

when i create custom Link, after creating the successful menu I was transferred to the home page. I think this problem is caused by Function addcustommenu in menu.js file. After successful creation, window.location = "" will be executed; makes me redirect to home page. I edited it into location.reload (); and everything works well.

Laravel version: 5.8
PHP Version: 7.2
OS: Centos 7.6
Webserver: Nginx

Cannot read property 'outerText' of undefined

Uncaught TypeError: Cannot read property 'outerText' of undefined
at HTMLLIElement. (menu.js:15)
at Function.each (app.js:18368)
at jQuery.fn.init.each (app.js:18163)
at getmenus (menu.js:6)
at HTMLAnchorElement.onclick (menu?menu=4:535)

Class harimayco-menu does not exist

I did all step by step procedure as mentioned in https://github.com/harimayco/wmenu-builder, but when i try running code

use Harimayco\Menu\Facades\Menu; $menuList = Menu::get(1);

i get error saying

(1/1) ReflectionException
Class harimayco-menu does not exist

can you please help to sort this issue

Update:

I fixed this issue by clearing cache and composer autodump, however i have a new issue.

SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: select * from `` where menu = 1 order by `sort` asc)

its not showing menu table name. can you please help on it

Regards

How to use menu builder

I am trying to bring up the menu builder. Can you please provide some steps in how to.

I looked at
@extends('app')

@section('contents')
{!! Menu::render() !!}
@endsection

//YOU MUST HAVE JQUERY LOADED BEFORE menu scripts
@Push('scripts')
{!! Menu::scripts() !!}
@endpush

I am not sure what route to use, what to call etc

Font awesome 5

Hi there

Using font awesome 5 which seems to break the carets for the drop downs

how to install for 5.6

Hi

Is there any way to install the menu for 5.6?

I run
composer require harimayco/laravel-menu

and I got that error

Problem 1
- Conclusion: don't install harimayco/laravel-menu 1.4.3
- Conclusion: don't install harimayco/laravel-menu 1.4.2
- Conclusion: don't install harimayco/laravel-menu 1.4.1
- Conclusion: remove laravel/framework v5.6.39
- Installation request for harimayco/laravel-menu ^1.4 -> satisfiable by harimayco/laravel-menu[1.4.0, 1.4.1, 1.4.2, 1.4.3].
- Conclusion: don't install laravel/framework v5.6.39

thanks

Laravel Blade Recursive

Hi, could you please help me understand how I can show the menu in the view.
I did not understand how I can only show the menu with infinite sub-levels.
I hope in your help and thanks for the excellent work

How to for newbie

Hi, I am a newbie with laravel. I've made simple CRUD. And I just installed this wmenu-builder. I did step 1 to 6, and now I don't know what to do after artisan migrate.
I checked my routes/web.php and nothing about menu. Please help me.
Thank you.

Return an empty array when the menu name not found

Hi. I made a change to the below file to return an empty array instead of non-object exception when the menu name is not found via getByName().

File: /vendor/harimayco/laravel-menu/src/WMenu.php

public static function getByName($name)
{
    $menu = Menus::byName($name);
    return is_null($menu) ? [] : self::get($menu->id);
}

Error publishing migration files

May be you have been miss referenced migration files name

$this->publishes([
DIR.'/../migrations/2017_08_11_073824_create_menus_table.php' => database_path('migrations/2017_08_11_073824_create_menus_table.php'),
DIR.'/../migrations/2017_08_11_074006_create_menu_items_table.php' => database_path('migrations/2017_08_11_074006_create_menu_items_table.php'),
], 'migrations');

but your migration files are
2017_08_11_073824_create_menus_wp_table.php and 2017_08_11_074006_create_menu_items_wp_table.php

Thx

Roles Reset to null

Thanks for this package.
But, I have some problem, when I create a new menu item then I choose the role, it saved to DB, but when I update it, it reset to null.

can you help me?

thank you

foreach not working on blade template

"Trying to get property of non-object (View: F:\xampp\htdocs\wmenu-builder\resources\views\layouts\app.blade.php) (View: F:\xampp\htdocs\wmenu-builder\resources\views\layouts\app.blade.php)

@foreach($menuList as $main)
<li><a href="{{ $main->link }}">{{ $main->label }}</a></li>
@endforeach

Class 'Menu' not found

I am trying to bring up the builder in my admin page for building a menu.

My Controller:

use Harimayco\Menu\Models\Menus;
use Harimayco\Menu\Models\MenuItems;
........

 public function index()
    {
        return view('admin.menu.index-menu');
    }

Blade Template:

inside the blade template

{!! Menu::render() !!}

........

{!! Menu::scripts() !!}

I am not sure what else I should do... I have followed exactly. Does the package not create the model Menu?

Thanks so much

Error Migrate

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (idint unsigned not null auto_increment primary key,namevarchar(191) not null,created_attimestamp null,updated_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Thanks

Route not working..

i just apply all functions. but when i try to update anything. then route not wroking?? please solve issue laravel 7.x
Annotation 2020-03-16 172652
Annotation 2020-03df16 172652

Style Issue

Hi
I have a problem with the CSS style.
My admin panel is like this screenshot.
5

I even removed all of my CSSs in my project but the problem still remains.
What should I do?
I'm using Laravel 5.8.

add SCSS

please add SCSS style file . i need use it rtl vertion

TokenMismatchException

VerifyCsrfToken.php (line 68) when create menu or add menu items in menu on laravel 5.5

Installation faild on laravel 5.8

On installing harimayco/wmenu-builder package i am facing following error:

D:\wamp64\www\others\cms>composer require harimayco/laravel-menu
Using version ^1.3 for harimayco/laravel-menu
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi

In Model.php line 1249:

Call to a member function connection() on null

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json to its original content.

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.