diff --git a/app/Models/PushSubscription.php b/app/Models/PushSubscription.php index e72b4a1..566f101 100644 --- a/app/Models/PushSubscription.php +++ b/app/Models/PushSubscription.php @@ -6,14 +6,15 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphTo; #[Guarded(['id'])] class PushSubscription extends Model { use HasFactory; - public function user(): BelongsTo + public function user(): MorphTo { - return $this->belongsTo(User::class); + return $this->morphTo(); } } diff --git a/app/Models/User.php b/app/Models/User.php index 0c54243..f3217f9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; + use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -37,21 +38,21 @@ protected function casts(): array protected function email(): Attribute { return Attribute::make( - set: fn (string $value) => strtolower($value), + set: fn(string $value) => strtolower($value), ); } protected function name(): Attribute { return Attribute::make( - get: fn () => $this->userProfile?->full_name ?? '', + get: fn() => $this->userProfile?->full_name ?? '', ); } protected function fullName(): Attribute { return Attribute::make( - get: fn () => $this->userProfile?->full_name ?: $this->username, + get: fn() => $this->userProfile?->full_name ?: $this->username, ); } @@ -181,11 +182,6 @@ public function purchaseItems(): HasMany return $this->hasMany(PurchaseItem::class); } - public function pushSubscriptions(): HasMany - { - return $this->hasMany(PushSubscription::class); - } - public function rejections(): HasMany { return $this->hasMany(Rejection::class, 'rejected_by_id');