| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- use App\Authority;
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- class CreateCustomersTable extends Migration
- {
- protected $authNames=[
- '客户管理',
- '客户管理-项目',
- '客户管理-项目-报表',
- '客户管理-项目-查询',
- '客户管理-项目-录入',
- '客户管理-项目-面积',
- '客户管理-财务-即时账单',
- '客户管理-财务-账单确认',
- '计费模型-仓储',
- '计费模型-仓储-录入',
- '客户',
- '客户-查询',
- '客户-录入',
- '项目组',
- '项目组-查询',
- '项目组-录入',
- '作业类型',
- '作业类型-查询',
- '作业类型-录入',
- '特征',
- '特征-录入',
- '特征-查询',
- '计费模型-作业',
- '计费模型-作业-查询',
- '计费模型-作业-录入',
- ];
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('customers', function (Blueprint $table) {
- $table->id();
- $table->string('code')->unique()->comment('客户代码');
- $table->string('name')->comment('客户名称');
- $table->string('company_name')->comment('公司名称');
- $table->timestamps();
- });
- foreach ($this->authNames as $name){
- if(!Authority::query()->where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
- }
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('customers');
- foreach ($this->authNames as $name){
- Authority::query()->where('name',$name)->delete();
- }
- }
- }
|