Procházet zdrojové kódy

角色增加劳务所关联表,相因迁移文件

hu hao před 4 roky
rodič
revize
5305d74b7d

+ 31 - 0
database/migrations/2021_06_07_140812_create_role_labor_company_table.php

@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateRoleLaborCompanyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('role_labor_company', function (Blueprint $table) {
+            $table->bigInteger("role_id")->comment("外键角色");
+            $table->bigInteger("labor_company_id")->comment("外键劳务所");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('role_labor_company');
+    }
+}

+ 35 - 0
database/migrations/2021_06_07_141732_add_labor_company_authoritiy.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddLaborCompanyAuthoritiy extends Migration
+{
+    protected $authorities = [
+        "劳务所-可见全部",
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        foreach ($this->authorities as $authority){
+            \App\Authority::query()->firstOrCreate(["alias_name"=>$authority],["name"=>$authority,"alias_name"=>$authority]);
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        foreach ($this->authorities as $authority){
+            \App\Authority::query()->where("alias_name",$authority)->delete();
+        }
+    }
+}