Blueprint 通过配置文件快速完成 Laravel 数据库迁移、模型类、工厂类等组件的编排和创建:
$ composer require --dev laravel-shift/blueprint
$ php artisan blueprint:new --config
models:
Department:
uuid: uuid
name: string:50
description: longtext
relationships:
hasMany: Employee
Employee:
uuid: uuid
full_name: string:100
email: string:100 index
department_id: id foreign
job_title: string:50
payment_type: string:20
salary: integer unsigned nullable
hourly_rate: integer unsigned nullable
- 运行如下命令即可生成对应的模型类、数据库迁移以及模型工厂:
$ php artisan blueprint:build
Created:
- database/factories/DepartmentFactory.php
- database/factories/EmployeeFactory.php
- database/migrations/2022_12_28_075857_create_departments_table.php
- database/migrations/2022_12_28_075858_create_employees_table.php
- app/Models/Department.php
- app/Models/Employee.php
$ php artisan migrate
网友评论