| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- use App\Authority;
- use App\CustomField;
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- class CreateCustomFieldsTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('custom_fields', function (Blueprint $table) {
- $table->id();
- $table->string('table')->index()->comment('定义目标的表');
- $table->string('field')->index()->comment('定义目标表的字段');
- $table->string('present_name')->index()->comment('所呈现的字段名');
- $table->string('authority_id')->comment('对应的权限');
- $table->string('condition_field')->nullable()->comment('条件字段,用来作为定义该字段权限和显示名的依据');
- $table->string('condition_value')->nullable()->comment('条件字段值,用来作为定义该字段权限和显示名的依据');
- $table->timestamps();
- });
- // if(!Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first())(new Authority(['name'=>'退货管理-查询-客户定义-爱奇艺','alias_name'=>'退货管理-查询-客户定义-爱奇艺']))->save();
- // $authority=Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first();
- // CustomField::create(['table'=>'rejected_bills','field'=>'common_01','present_name'=>'寄件方省','authority_id'=>$authority['id'],'condition_field'=>'id_owner','condition_value'=>'66']);
- // CustomField::create(['table'=>'rejected_bills','field'=>'common_02','present_name'=>'退件重量','authority_id'=>$authority['id'],'condition_field'=>'id_owner','condition_value'=>'66']);
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('custom_fields');
- }
- }
|