patilvishalvs/generic_crud

适用于 Laravel MVC 的通用 CRUD

v1.3 2019-08-19 11:44 UTC

This package is auto-updated.

Last update: 2024-09-19 23:33:00 UTC


README

创建新的 Laravel 项目

laravel new <project_name>

安装包

composer require patilvishalvs/generic_crud

在 AppServiceProvider.php 中更新默认字符串长度

//Add following line in AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
...
public function boot()
{
    ...
    //Add following line in boot() function of AppServiceProvider.php
    Schema::defaultStringLength(191);
}

迁移数据库并启用 auth

php artisan migrate
php artisan make:auth

在 User.php 文件中添加以下行以启用 ACL

// Use class HasRolesTrait
use PatilVishalVS\GenericCRUD\HasRolesTrait;
...
//Add trait to User model as follow
...
use Notifiable, HasRolesTrait;

在 Kernel.php 中注册新的中间件

protected $routeMiddleware = [
  ...
    'generic_crud' => \PatilVishalVS\GenericCRUD\GenericAuthMiddleware::class,
];

播种和发布供应商资源和资产,然后提供服务

php artisan db:seed --class="PatilVishalVS\GenericCRUD\seeds\DatabaseSeeder"
php artisan vendor:publish --tag=public
php artisan vendor:publish --tag=resources
php artisan serve