EmailLog.php 718 字节
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Log;

/**
 * 邮件日志记录,一般只用于观察
 * @time 2022/7/29 15:09
 * Class EmailList
 * @package App\Mail\Models
 */
class EmailLog extends Model{


    public static function error($message){

        try {
            if($message instanceof \Throwable){
                $message = [$message->getMessage(),$message->getTraceAsString()];
            }

            static::insert([
                'error' =>  print_r($message,true),
                'datetime'  =>  date('Y-m-d H:i:s')
            ]);
        }catch (\Throwable $e){
            Log::error(print_r($message,true));
        }

    }

}