🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 21:09:07 +01:00
parent 19269de238
commit c63995a6d5
2 changed files with 17 additions and 17 deletions
+16 -16
View File
@@ -102,12 +102,12 @@ class Article extends Model
public function comments(): HasMany public function comments(): HasMany
{ {
return $this->hasMany(ArticleComment::class); return $this->hasMany(ArticleComment::class)->defaultBehavior();
} }
public function reactions(): HasMany public function reactions(): HasMany
{ {
return $this->hasMany(ArticleReaction::class); return $this->hasMany(ArticleReaction::class)->defaultBehavior();
} }
public function user() public function user()
@@ -115,25 +115,25 @@ class Article extends Model
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }
public function tags() public function tags(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{ {
return $this->morphToMany(Tag::class, 'taggable'); return $this->morphToMany(Tag::class, 'taggable');
} }
protected function titleColor(): Attribute // protected function titleColor(): Attribute
{ // {
return new Attribute( // return new Attribute(
get: fn () => isDarkColor($this->predominant_color) ? '#fff' : '#000', // get: fn () => isDarkColor($this->predominant_color) ? '#fff' : '#000',
); // );
} // }
public function createFollowersNotification(): void // public function createFollowersNotification(): void
{ // {
$this->user->followers() // $this->user->followers()
->with('user:id,username') // ->with('user:id,username')
->each(fn (AuthorNotification $follower) => $follower->user->notify($this->user, NotificationType::ArticlePosted, $this->getNotificationUrl()), // ->each(fn (AuthorNotification $follower) => $follower->user->notify($this->user, NotificationType::ArticlePosted, $this->getNotificationUrl()),
); // );
} // }
protected function casts(): array protected function casts(): array
{ {
return [ return [
@@ -32,7 +32,7 @@ class WebsiteArticleReaction extends Model
static::creating(function ($model): void { static::creating(function ($model): void {
/** @var WebsiteArticleReaction $model */ /** @var WebsiteArticleReaction $model */
$model->user_id = (int) (auth()->id() ?? 0); $model->user_id = max(0, (int) (auth()->id() ?? 0));
}); });
} }