added email subscriptions

This commit is contained in:
2024-09-27 22:17:39 +10:00
parent b10b6b712e
commit 9b1b92d0cf
2 changed files with 59 additions and 0 deletions

30
app/Models/SentEmail.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class SentEmail extends Model
{
protected $fillable = ['recipient', 'mailable_class'];
public $incrementing = false;
protected $keyType = 'string';
/**
* Boot function from Laravel.
*
* @return void
*/
protected static function boot(): void
{
parent::boot();
static::creating(function ($model) {
if (empty($model->{$model->getKeyName()}) === true) {
$model->{$model->getKeyName()} = strtolower(Str::random(15));
}
});
}
}