2020_06_12_135840_create_custom_fields_table.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use App\Authority;
  3. use App\CustomField;
  4. use Illuminate\Database\Migrations\Migration;
  5. use Illuminate\Database\Schema\Blueprint;
  6. use Illuminate\Support\Facades\Schema;
  7. class CreateCustomFieldsTable extends Migration
  8. {
  9. /**
  10. * Run the migrations.
  11. *
  12. * @return void
  13. */
  14. public function up()
  15. {
  16. Schema::create('custom_fields', function (Blueprint $table) {
  17. $table->id();
  18. $table->string('table')->index()->comment('定义目标的表');
  19. $table->string('field')->index()->comment('定义目标表的字段');
  20. $table->string('present_name')->index()->comment('所呈现的字段名');
  21. $table->string('authority_id')->comment('对应的权限');
  22. $table->string('condition_field')->nullable()->comment('条件字段,用来作为定义该字段权限和显示名的依据');
  23. $table->string('condition_value')->nullable()->comment('条件字段值,用来作为定义该字段权限和显示名的依据');
  24. $table->timestamps();
  25. });
  26. CustomField::create(['table'=>'rejected_bills','field'=>'common_01','present_name'=>'寄件方省','authority_name'=>'退货管理-查询-客户定义-爱奇艺','condition_field'=>'id_owner','condition_value'=>'66']);
  27. CustomField::create(['table'=>'rejected_bills','field'=>'common_02','present_name'=>'退件重量','authority_name'=>'退货管理-查询-客户定义-爱奇艺','condition_field'=>'id_owner','condition_value'=>'66']);
  28. if(!Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first())(new Authority(['name'=>'退货管理-查询-客户定义-爱奇艺','alias_name'=>'退货管理-查询-客户定义-爱奇艺']))->save();
  29. }
  30. /**
  31. * Reverse the migrations.
  32. *
  33. * @return void
  34. */
  35. public function down()
  36. {
  37. Schema::dropIfExists('custom_fields');
  38. }
  39. }