2021_01_08_110607_add_default_email.php 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use App\Events\SendEmailEvent;
  3. use App\MailEvent;
  4. use Illuminate\Database\Migrations\Migration;
  5. use Illuminate\Database\Schema\Blueprint;
  6. use Illuminate\Support\Facades\Schema;
  7. class AddDefaultEmail extends Migration
  8. {
  9. protected $mailEvent;
  10. /**
  11. * Run the migrations.
  12. *
  13. * @return void
  14. */
  15. public function up()
  16. {
  17. //
  18. $this->mailEvent = (new MailEvent([
  19. 'name' => '发送默认邮件',
  20. 'event_name' => SendEmailEvent::class,
  21. 'remark' => null,
  22. 'is_active' => true,
  23. 'template' => json_encode([
  24. 'title' => '邮件测试',
  25. 'description' => '这是一封测试邮件,收到不用回复'
  26. ]),
  27. ]))->save();
  28. }
  29. /**
  30. * Reverse the migrations.
  31. *
  32. * @return void
  33. */
  34. public function down()
  35. {
  36. $this->mailEvent->delete();
  37. }
  38. }