如何在laravel 5.1中创建动态菜单? [英] How to create Dynamic menus in laravel 5.1?

查看:142
本文介绍了如何在laravel 5.1中创建动态菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站,我需要创建诸如wordpress之类的动态菜单.但是,我是laravel的新手.

推荐:

http://learninglaravel.net/laravel-dynamic-menu-tutorial/link

http://laravel.io/forum/04-16 -2014-dynamic-menu-system

https://laracasts.com/discuss/channels/general-discussion /dynamic-menu

解决方案

最好不要迟到,但是我也刚刚开始学习Laravel.从以下基本教程开始.这可能对您或阅读此问题的其他人有用.

跳过第一步,如果您只是想将第一个链接立即集成到软件包中.

1:

首先,我只是将以下内容保存在我的项目文件夹中,以使其正常工作. 笔记!阅读下面的注释,因为表中的角色"和角色"中有错别字.第二:如果您已经使用laravel中的"migration"和"seed"文件创建了"users"表, 在用户"表中添加一个"role_id"字段.本教程与Lavarel的内置授权/登录一起使用.您可能想先弄清楚这一点.

https://gist.github.com/drawmyattention/8cb599ee5dc0af5f4246

2:

稍后,我只是按照以下说明为软件包做基本设置:

https://laracasts.com/discuss/channel/tips/developing-your-packages-in-laravel-5

3:

如果您需要任何css,javascript或查看从软件包复制到项目文件夹的文件,请阅读以下内容:

http://laravel.com/docs/5.0/packages

4:

然后,最后尝试弄清您的Menu东西实际上在做什么.请点击第一个链接,以获取有关如何做事的提示.

是否要检索可能是菜单项的所有控制器和操作的列表?有可能,但是您可能必须用谷歌搜索.

并且在将这些生成的列表项之一添加到菜单时:使用ajax创建动作以将菜单项添加到数据库. 从数据库中的视图模板中获取这些项并创建菜单,我想它们会使用"facade"类,但如果我错了,请纠正我.外观类可以称为Menu::create_menu_items();,我将尝试同样的事情,并逐步实现.

I am developing an website there I need to create dynamic menus like wordpress .but i am new to laravel .before asking question here, followed below tutorial but didn't got how to do?

Refereed:

http://learninglaravel.net/laravel-dynamic-menu-tutorial/link

http://laravel.io/forum/04-16-2014-dynamic-menu-system

https://laracasts.com/discuss/channels/general-discussion/dynamic-menu

解决方案

Better late then never, but I've just started learning Laravel too. Start with the following basic tutorials. It might be usefull for you or someone else who reads this question.

Skip the first step if you just want to integrate your first link into a package right away.

1:

First I've just dumped the following in my project folder just to make it work. NOTE! Read the comments below because there is a typo in the tables "role" and "roles" somewhere. Second of all: if you already have a "users" table by using the "migration" and "seed" files that are present in laravel, Add a "role_id" field to the "users" table. The tutorial works with the build-in authorization / login from Lavarel. You might want to figure that out first.

https://gist.github.com/drawmyattention/8cb599ee5dc0af5f4246

2:

Later on I've followed the following instructions just to make a basic setup for a package:

https://laracasts.com/discuss/channels/tips/developing-your-packages-in-laravel-5

3:

If you need any css, javascript or view files copied from your package to your project folder read the following:

http://laravel.com/docs/5.0/packages

4:

Then at last, try to figure out what your Menu thingie is actualy doing. Take your first link to get some inspitation about how to do stuff.

Do you want to retrieve a list of all controllers and actions that might be menu-items? It's possible but you might have to google it.

And when you add one of those generated list items to a menu: create an action with ajax to add a menu-item to the database. Get those items from the database in a view-template and create the menu, I guess they use a "facade" class for it but correct me if I am wrong. A facade class can be called like Menu::create_menu_items(); I am going to try the same thing and realy do it step by step.

这篇关于如何在laravel 5.1中创建动态菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆