<?php

use App\Events\SendEmailEvent;
use App\MailEvent;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddDefaultEmail extends Migration
{
    protected $mailEvent;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        $this->mailEvent = (new MailEvent([
            'name' => '发送默认邮件',
            'event_name' => SendEmailEvent::class,
            'remark' => null,
            'is_active' => true,
            'template' => json_encode([
                'title' => '邮件测试',
                'description' => '这是一封测试邮件，收到不用回复'
            ]),
        ]))->save();

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $this->mailEvent->delete();
    }
}
