2020_06_12_135840_create_custom_fields_table.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // if(!Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first())(new Authority(['name'=>'退货管理-查询-客户定义-爱奇艺','alias_name'=>'退货管理-查询-客户定义-爱奇艺']))->save();
  27. // $authority=Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first();
  28. // CustomField::create(['table'=>'rejected_bills','field'=>'common_01','present_name'=>'寄件方省','authority_id'=>$authority['id'],'condition_field'=>'id_owner','condition_value'=>'66']);
  29. // CustomField::create(['table'=>'rejected_bills','field'=>'common_02','present_name'=>'退件重量','authority_id'=>$authority['id'],'condition_field'=>'id_owner','condition_value'=>'66']);
  30. }
  31. /**
  32. * Reverse the migrations.
  33. *
  34. * @return void
  35. */
  36. public function down()
  37. {
  38. Schema::dropIfExists('custom_fields');
  39. }
  40. }