diplodocker / foreign-loader
此包已废弃且不再维护。未建议替代包。
Laravel外键加载助手(Diplodocker项目的一部分)
0.0.1
2019-03-04 18:31 UTC
Requires
- php: ^7.1.3
This package is auto-updated.
Last update: 2022-01-04 17:13:18 UTC
README
Diplodocker项目助手
安装
- 安装 laravel =)
composer require --dev diplodocker/foreign-loader
使用类
<?php use Diplodocker\ForeignKeysMigration; class SomeMigrationFileName extends ForeignKeysMigration { public $keys = [ 'user.city_id' => 'city.id', 'user.company_id' => 'company.id', ... ];
或使用特性
<?php use Diplodocker\Concerns\ForeignLoader; use Illuminate\Database\Migrations\Migration; class SomeMigrationFileName extends Migration { // use trait use ForeignLoader; // set ON_UPDATE and ON_DELETE actions public const ON_UPDATE = 'restrict'; public const ON_DELETE = 'restrict'; public $keys = [ 'user.city_id' => 'city.id', 'user.company_id' => 'company.id', ... ]; /** * Run the migrations. * * @return void */ public function up() { // your code here $this->loadForeignKeys(); } /** * Reverse the migrations. * * @return void */ public function down() { // your code here $this->dropForeignKeys(); }