ldc-crm/app/Models/SingleOptin.php
2023-06-30 14:59:47 +02:00

66 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class SingleOptin extends Model
{
use HasFactory;
/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = 'hashcode';
/**
* The "type" of the primary key ID.
*
* @var string
*/
protected $keyType = 'uuid';
/**
* Indicates if the IDs are auto-incrementing.
*
* @var boolean
*/
public $incrementing = false;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'email'
];
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted()
{
static::creating(function (self $model) {
$model->hashcode = Str::uuid();
});
}
// * RELATIONS
/**
* Brand BelongsTo relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function brand()
{
return $this->belongsTo(Brand::class);
}
}