maxcxam / laravel-generator-extended
扩展 Laravel 9 迁移创建器
1.2.2.7
2023-02-12 16:36 UTC
Requires
- php: >=8.1
- illuminate/console: ~9.0
- illuminate/contracts: ~9.0
- illuminate/filesystem: ~9.0
- illuminate/support: ~9.0
README
L5 包含一些内置的生成器,因此此包只需要添加一些东西,例如
make:entitymake:entity {ModelName}
Laravel 9 的使用方法
步骤 1:通过 Composer 安装
composer require maxcxam/laravel-generator-extended
步骤 2:添加服务提供者
您只希望将这些生成器用于本地开发,因此您不希望更新生产环境中的 providers 数组在 config/app.php 中。相反,在 app/Providers/AppServiceProvider.php 中添加提供者,如下所示
public function register() { if ($this->app->environment() == 'development') { $this->app->register('Maxcxam\Generators\GeneratorsServiceProvider'); } }
步骤 3:运行 Artisan!
您已设置完毕。从控制台运行 php artisan,您将看到 make:* 命名空间部分中的新命令。
示例
具有架构的迁移
php artisan make:model Product
回答一些关于字段名称、类型、可空性、关系等问题
...
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('username'); $table->string('email')->nullable(FALSE); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('users'); } }
Available Relations is 'ManyToOne', 'ManyToMany'
Available field types is 'string', 'text', 'array'