diff --git a/Updated_Cms/app/Models/Article.php b/Updated_Cms/app/Models/Article.php index 8f2a2a23f9..bc5b89ef40 100644 --- a/Updated_Cms/app/Models/Article.php +++ b/Updated_Cms/app/Models/Article.php @@ -102,12 +102,12 @@ class Article extends Model public function comments(): HasMany { - return $this->hasMany(ArticleComment::class); + return $this->hasMany(ArticleComment::class)->defaultBehavior(); } public function reactions(): HasMany { - return $this->hasMany(ArticleReaction::class); + return $this->hasMany(ArticleReaction::class)->defaultBehavior(); } public function user() @@ -115,25 +115,25 @@ class Article extends Model return $this->belongsTo(User::class); } - public function tags() + public function tags(): \Illuminate\Database\Eloquent\Relations\MorphToMany { return $this->morphToMany(Tag::class, 'taggable'); } - protected function titleColor(): Attribute - { - return new Attribute( - get: fn () => isDarkColor($this->predominant_color) ? '#fff' : '#000', - ); - } + // protected function titleColor(): Attribute + // { + // return new Attribute( + // get: fn () => isDarkColor($this->predominant_color) ? '#fff' : '#000', + // ); + // } - public function createFollowersNotification(): void - { - $this->user->followers() - ->with('user:id,username') - ->each(fn (AuthorNotification $follower) => $follower->user->notify($this->user, NotificationType::ArticlePosted, $this->getNotificationUrl()), - ); - } + // public function createFollowersNotification(): void + // { + // $this->user->followers() + // ->with('user:id,username') + // ->each(fn (AuthorNotification $follower) => $follower->user->notify($this->user, NotificationType::ArticlePosted, $this->getNotificationUrl()), + // ); + // } protected function casts(): array { return [ diff --git a/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php b/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php index 7b3077b8aa..479a6169f4 100644 --- a/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php +++ b/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php @@ -32,7 +32,7 @@ class WebsiteArticleReaction extends Model static::creating(function ($model): void { /** @var WebsiteArticleReaction $model */ - $model->user_id = (int) (auth()->id() ?? 0); + $model->user_id = max(0, (int) (auth()->id() ?? 0)); }); }