53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\NotificationType;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
class Notifications extends Model
|
|
{
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array<string,string>
|
|
*/
|
|
protected $casts = [
|
|
'type' => NotificationType::class
|
|
];
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<integer, string>
|
|
*/
|
|
protected $fillable = [
|
|
'type',
|
|
'content',
|
|
'customer_id'
|
|
];
|
|
|
|
// * RELATIONSHIPS
|
|
|
|
/**
|
|
* Get the customer that owns the Notifications
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
/**
|
|
* Polymorphic relation : Get the parent model
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
|
*/
|
|
public function notifiable(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
}
|