<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class MailQueue extends Model
{
    protected $keyType = 'string';
    public $incrementing = false;

    protected $fillable = [
        'user_id',
        'to',
        'subject',
        'body',
        'meta',
        'tries',
        'template',
        'locale',
        'status',
        'max_tries',
        'available_at',
        'sent_at',
        'error',
        'template',
        'locale',
    ];

    protected $casts = [
        'meta' => 'array',
        'available_at' => 'datetime',
        'sent_at' => 'datetime',
    ];

    protected static function boot()
    {
        parent::boot();

        static::creating(function ($model) {
            if (!$model->id) {
                $model->id = (string) Str::uuid();
            }
        });
    }


}
