2020-12-01 17:02:10 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2023-06-26 15:10:28 +02:00
|
|
|
use Illuminate\Support\Str;
|
2020-12-01 17:02:10 +01:00
|
|
|
|
2023-09-06 17:24:53 +02:00
|
|
|
/**
|
|
|
|
|
* @property integer $hashcode Hashcode.
|
|
|
|
|
* @property integer $brand_id Foreign key Brand.
|
|
|
|
|
* @property string $email Email.
|
|
|
|
|
* @property-read \Illuminate\Support\Carbon $created_at Created date.
|
|
|
|
|
* @property-read \Illuminate\Support\Carbon $updated_at Updated date.
|
|
|
|
|
|
|
|
|
|
* @property-read \App\Models\Brand $brand Brand BelongsTo relation.
|
|
|
|
|
*/
|
2020-12-02 10:08:27 +01:00
|
|
|
class SingleOptin extends Model
|
2020-12-01 17:02:10 +01:00
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
2023-06-26 15:10:28 +02:00
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var string[]
|
|
|
|
|
*/
|
2021-03-14 10:45:42 +01:00
|
|
|
protected $fillable = [
|
2023-09-04 13:08:34 +02:00
|
|
|
'email',
|
2021-03-14 10:45:42 +01:00
|
|
|
];
|
|
|
|
|
|
2023-06-26 15:10:28 +02:00
|
|
|
/**
|
|
|
|
|
* Perform any actions required after the model boots.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
protected static function booted(): void
|
2023-06-26 15:10:28 +02:00
|
|
|
{
|
|
|
|
|
static::creating(function (self $model) {
|
|
|
|
|
$model->hashcode = Str::uuid();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
// * RELATIONS
|
|
|
|
|
|
2021-02-28 12:04:49 +01:00
|
|
|
/**
|
2023-09-06 17:24:53 +02:00
|
|
|
* Brand BelongsTo relation.
|
2021-02-28 12:04:49 +01:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2021-02-28 12:04:49 +01:00
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Brand::class);
|
2020-12-01 17:02:10 +01:00
|
|
|
}
|
|
|
|
|
}
|