*/ protected $fillable = [ 'type', 'content', 'customer_id', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'type' => NotificationType::class, ]; // * METHODS /** * Created at nice date. */ public function createdAtNiceDate(): Attribute { return Attribute::make( get: fn () => (new NiceDate())->get(null, '', $this->created_at, []) ); } /** * Get notifications. */ public static function getNotifications(): void { if (! Auth::guard('club')->check()) { return; } /** @var \App\Models\Customer $customerModel */ $customerModel = Auth::guard('club')->user(); $notifications = $customerModel->getAllNotifications(); View::share('notifications', count($notifications) - $customerModel->readNotifications()->count()); View::share('notificationsList', $notifications); } // * RELATIONSHIPS /** * Get the customer that owns the Notifications. */ public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } /** * Polymorphic relation : Get the parent model. */ public function notifiable(): MorphTo { return $this->morphTo(); } }