2021_03_01_150232_create_delivery_appointments_table.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateDeliveryAppointmentsTable extends Migration
  6. {
  7. public $authorities = [
  8. "入库管理-盘收一体-客户预约",
  9. ];
  10. /**
  11. * Run the migrations.
  12. *
  13. * @return void
  14. */
  15. public function up()
  16. {
  17. Schema::create('delivery_appointments', function (Blueprint $table) {
  18. $table->id();
  19. $table->timestamps();
  20. });
  21. foreach ($this->authorities as $authority){
  22. \App\Authority::query()->firstOrCreate([
  23. "name"=>$authority
  24. ],[
  25. "name"=>$authority,
  26. "alias_name"=>$authority
  27. ]);
  28. }
  29. }
  30. /**
  31. * Reverse the migrations.
  32. *
  33. * @return void
  34. */
  35. public function down()
  36. {
  37. Schema::dropIfExists('delivery_appointments');
  38. foreach ($this->authorities as $authority){
  39. \App\Authority::query()->where("name",$authority)->delete();
  40. }
  41. }
  42. }