lais/scaffold

1.0.5 2016-12-21 10:03 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:58:58 UTC


README

该包辅助创建 CRUD

$ php artisan make:scaffold Cliente --schema="nome:string, telefone:string, data_nascimento:date" --plural="Clientes" --singular="Cliente"
$ php artisan make:scaffold Instituicao --schema="nome:string('200'):default('LAIS'), cnpj:string:nullable, quantidade_funcionarios:integer" -p Clientes -s Cliente

摘要

它能做什么

它创建了一个带有所有方法 --resources 的 CRUD,包括

  • 视图:index, show, create, edit
  • CrudController(实现了方法)
  • (My)Controller,继承自 CrudController
  • 迁移遵循命令的 --schema 参数定义
  • 在 routes/web.php 文件中添加路由
Route::resource('my', 'MyController');

要求

安装

Composer 在终端中执行以下命令

$ composer require lais/scaffold

在 Laravel 中注册命令 打开文件 app/Console/Kernel.php 并将以下类添加到数组 $commands

protected $commands = [
    \LAIS\Scaffold\Console\Commands\Scaffolding::class,
];

在 Laravel 中注册 provider 打开文件 config/app.php 并在选项的数组 providers 中添加以下行

\LAIS\Scaffold\Providers\LaisServiceProvider::class,

如何使用

Artisan 命令

$ php artisan make:scaffold Cliente --schema="coluna1:tipo1, coluna2:tipo2..." --plural="Clientes" --singular="Cliente"
$ php artisan make:scaffold Empresa --schema="coluna1:tipo1:modificador1, coluna2:tipo2..." -p Clientes -s Cliente

参数传递遵循 Laravel 5.3 的迁移标准