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
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。