*/ protected $fillable = [ 'type', 'content', 'customer_id' ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'type' => NotificationType::class ]; // * RELATIONSHIPS /** * Get the customer that owns the Notifications * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function customer(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Customer::class); } /** * Polymorphic relation : Get the parent model * * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ public function notifiable(): \Illuminate\Database\Eloquent\Relations\MorphTo { return $this->morphTo(); } // * METHODS /** * created_at_nice_date attribute * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ public function createdAtNiceDate(): \Illuminate\Database\Eloquent\Casts\Attribute { return Attribute::make( get: fn () => (new NiceDate())->get(null, '', $this->created_at, []) ); } }