| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?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->timestamp('created_at');
- });
- 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();
- }
- }
- }
|