如何在现有项目上使用Backpack for Laravel? [英] How to use Backpack for Laravel on existing project?

查看:348
本文介绍了如何在现有项目上使用Backpack for Laravel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Laravel开发一个小应用程序,我发现背包看起来非常漂亮!

I'm building a small app with Laravel and I juste discovered Backpack that looks very nice !

我下载了它(有许可证),但是我真的不知道如何将它与现有文件(到目前为止有3个控制器,3个模型和一些刀片文件)一起使用

I downloaded it (I have a license), but I really don't know how to use it with my existing files (so far 3 controllers, 3 models and a few blade files)

也许答案在文档中的某个位置,但是我找不到它..

Maybe the answer is somewhere in the documentation, but I could not find it..

详细的解释将不胜感激!

A detailed explanation would be mutch appreciated !

谢谢大家,祝你愉快!

来自法国的欢呼声

推荐答案

假设您有一个名为Person的模型...

suppose you have model called Person ...

php artisan backpack:crud Person

生成的命令将告诉您该模型已存在...它将为您生成路线和Crud Controller ...

the generated command will tell you that the model is existed... and it will generate the routes and Crud Controller for you ...

然后转到模型...在使用"部分中添加:

then you go to your model ... in 'use' section add:

use Backpack\CRUD\app\Models\Traits\CrudTrait;

并在您的模型主体中...添加

and in your model body ... add

 use CrudTrait;

您还可以覆盖视图...女巫,我不建议您这样做,除非您有充分的理由

you can also override the views ... witch i do not recommend unless you have good reason for that

https://backpackforlaravel.com/docs/4.1/upgrade-guide#views

这篇关于如何在现有项目上使用Backpack for Laravel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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