2020_12_15_095959_add_customer_phone_address.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class AddCustomerPhoneAddress extends Migration
  6. {
  7. protected $authorities = [
  8. "客户-客户状态",
  9. "客户-客户状态-查询",
  10. "客户-客户状态-录入",
  11. "客户-客户状态-编辑",
  12. "客户-客户状态-删除",
  13. ];
  14. /**
  15. * Run the migrations.
  16. *
  17. * @return void
  18. */
  19. public function up()
  20. {
  21. Schema::table('customers', function (Blueprint $table) {
  22. $table->string('invoice_address')->nullable()->comment('发票地址');
  23. $table->string('contact_man')->index()->nullable()->comment('联系人');
  24. $table->string('phone')->nullable()->comment('联系电话');
  25. $table->string('remark')->nullable()->comment('公司备注');
  26. });
  27. foreach ($this->authorities as $authority){
  28. \App\Authority::query()->firstOrCreate([
  29. "name" => $authority,
  30. "alias_name" => $authority,
  31. ]);
  32. }
  33. }
  34. /**
  35. * Reverse the migrations.
  36. *
  37. * @return void
  38. */
  39. public function down()
  40. {
  41. Schema::table('customers',function (Blueprint $table){
  42. $table->dropColumn('invoice_address');
  43. $table->dropColumn('contact_man');
  44. $table->dropColumn('phone');
  45. $table->dropColumn('remark');
  46. });
  47. foreach ($this->authorities as $authority){
  48. \App\Authority::query()->where("name",$authority)->where("alias_name",$authority)->delete();
  49. }
  50. }
  51. }