From 8d3115678cc9a9fd9c6950e2d7b7ff7563374a77 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 19 Jan 2026 21:04:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=99=20More=20fixes=20=F0=9F=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Updated_Cms/app/Models/Articles/Tag.php | 9 +++++---- .../app/Models/Articles/WebsiteArticle.php | 17 +++++++++++++++- .../Models/Articles/WebsiteArticleComment.php | 6 ++++++ .../Articles/WebsiteArticleReaction.php | 12 +++++++---- Updated_Cms/app/Models/ChatlogPrivate.php | 10 +++++++--- Updated_Cms/app/Models/ChatlogRoom.php | 20 +++++++++++++------ Updated_Cms/app/Models/CommandLog.php | 7 ++++--- .../Community/RareValue/WebsiteRareValue.php | 6 ++++++ .../RareValue/WebsiteRareValueCategory.php | 3 +++ .../Staff/WebsiteStaffApplications.php | 6 ++++++ 10 files changed, 75 insertions(+), 21 deletions(-) diff --git a/Updated_Cms/app/Models/Articles/Tag.php b/Updated_Cms/app/Models/Articles/Tag.php index 2c5f2e0c6c..9b7e7fa1e6 100644 --- a/Updated_Cms/app/Models/Articles/Tag.php +++ b/Updated_Cms/app/Models/Articles/Tag.php @@ -2,16 +2,17 @@ namespace App\Models\Articles; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\MorphToMany; class Tag extends Model { - use HasFactory; - protected $guarded = []; - public function websiteArticles() + /** + * @return MorphToMany + */ + public function websiteArticles(): MorphToMany { return $this->morphedByMany(WebsiteArticle::class, 'taggable'); } diff --git a/Updated_Cms/app/Models/Articles/WebsiteArticle.php b/Updated_Cms/app/Models/Articles/WebsiteArticle.php index 5d7e7ebee7..34ac4e5414 100644 --- a/Updated_Cms/app/Models/Articles/WebsiteArticle.php +++ b/Updated_Cms/app/Models/Articles/WebsiteArticle.php @@ -6,6 +6,8 @@ use App\Models\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; +use App\Models\Articles\Tag; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\Auth; use Spatie\Sluggable\HasSlug; @@ -25,17 +27,26 @@ class WebsiteArticle extends Model ->usingSeparator('-')->allowDuplicateSlugs(); } + /** + * @return BelongsTo + */ public function user(): BelongsTo { return $this->belongsTo(User::class); } + /** + * @return HasMany + */ public function reactions(): HasMany { return $this->hasMany(WebsiteArticleReaction::class, 'article_id') ->whereActive(true); } + /** + * @return HasMany + */ public function comments(): HasMany { return $this->hasMany(WebsiteArticleComment::class, 'article_id'); @@ -52,13 +63,17 @@ class WebsiteArticle extends Model parent::boot(); static::saving(function ($model): void { + /** @var WebsiteArticle $model */ if (empty($model->image)) { $model->image = ''; } }); } - public function tags() + /** + * @return MorphToMany + */ + public function tags(): MorphToMany { return $this->morphToMany(Tag::class, 'taggable'); } diff --git a/Updated_Cms/app/Models/Articles/WebsiteArticleComment.php b/Updated_Cms/app/Models/Articles/WebsiteArticleComment.php index e1c390bf89..89548c57df 100644 --- a/Updated_Cms/app/Models/Articles/WebsiteArticleComment.php +++ b/Updated_Cms/app/Models/Articles/WebsiteArticleComment.php @@ -11,11 +11,17 @@ class WebsiteArticleComment extends Model { protected $guarded = ['id', 'created_at', 'updated_at']; + /** + * @return BelongsTo + */ public function article(): BelongsTo { return $this->belongsTo(WebsiteArticle::class, 'article_id'); } + /** + * @return BelongsTo + */ public function user(): BelongsTo { return $this->belongsTo(User::class); diff --git a/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php b/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php index cf86dfa5fe..027320fd82 100644 --- a/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php +++ b/Updated_Cms/app/Models/Articles/WebsiteArticleReaction.php @@ -3,14 +3,11 @@ namespace App\Models\Articles; use App\Models\User; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class WebsiteArticleReaction extends Model { - use HasFactory; - protected $guarded = []; public $timestamps = false; @@ -34,15 +31,22 @@ class WebsiteArticleReaction extends Model parent::boot(); static::creating(function ($model): void { - $model->user_id = auth()->id(); + /** @var WebsiteArticleReaction $model */ + $model->user_id = (int) auth()->id(); }); } + /** + * @return BelongsTo + */ public function article(): BelongsTo { return $this->belongsTo(WebsiteArticle::class, 'article_id'); } + /** + * @return BelongsTo + */ public function user(): BelongsTo { return $this->belongsTo(User::class); diff --git a/Updated_Cms/app/Models/ChatlogPrivate.php b/Updated_Cms/app/Models/ChatlogPrivate.php index a2d9ded115..c987a4d044 100644 --- a/Updated_Cms/app/Models/ChatlogPrivate.php +++ b/Updated_Cms/app/Models/ChatlogPrivate.php @@ -2,25 +2,29 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; +use App\Models\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class ChatlogPrivate extends Model { - use HasFactory; - protected $table = 'chatlogs_private'; protected $guarded = []; public $timestamps = false; + /** + * @return BelongsTo + */ public function sender(): BelongsTo { return $this->belongsTo(User::class, 'user_from_id'); } + /** + * @return BelongsTo + */ public function receiver(): BelongsTo { return $this->belongsTo(User::class, 'user_to_id'); diff --git a/Updated_Cms/app/Models/ChatlogRoom.php b/Updated_Cms/app/Models/ChatlogRoom.php index 66b728fcbd..16a66126b2 100644 --- a/Updated_Cms/app/Models/ChatlogRoom.php +++ b/Updated_Cms/app/Models/ChatlogRoom.php @@ -3,13 +3,12 @@ namespace App\Models; use App\Models\Game\Room; -use Illuminate\Database\Eloquent\Factories\HasFactory; +use App\Models\User; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class ChatlogRoom extends Model { - use HasFactory; - protected $table = 'chatlogs_room'; protected $guarded = []; @@ -18,17 +17,26 @@ class ChatlogRoom extends Model protected $primaryKey = 'timestamp'; - public function room() + /** + * @return BelongsTo + */ + public function room(): BelongsTo { return $this->belongsTo(Room::class); } - public function sender() + /** + * @return BelongsTo + */ + public function sender(): BelongsTo { return $this->belongsTo(User::class, 'user_from_id'); } - public function receiver() + /** + * @return BelongsTo + */ + public function receiver(): BelongsTo { return $this->belongsTo(User::class, 'user_to_id'); } diff --git a/Updated_Cms/app/Models/CommandLog.php b/Updated_Cms/app/Models/CommandLog.php index 80373b49b3..6220bdfb10 100644 --- a/Updated_Cms/app/Models/CommandLog.php +++ b/Updated_Cms/app/Models/CommandLog.php @@ -2,14 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; +use App\Models\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class CommandLog extends Model { - use HasFactory; - protected $table = 'commandlogs'; protected $primaryKey = 'timestamp'; @@ -18,6 +16,9 @@ class CommandLog extends Model public $timestamps = false; + /** + * @return BelongsTo + */ public function user(): BelongsTo { return $this->belongsTo(User::class); diff --git a/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValue.php b/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValue.php index a89c61e3a7..e4dc0f25e1 100644 --- a/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValue.php +++ b/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValue.php @@ -17,11 +17,17 @@ class WebsiteRareValue extends Model ]; } + /** + * @return BelongsTo + */ public function category(): BelongsTo { return $this->belongsTo(WebsiteRareValueCategory::class, 'category_id'); } + /** + * @return BelongsTo + */ public function item(): BelongsTo { return $this->belongsTo(CatalogItem::class, 'item_id', 'item_ids'); diff --git a/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValueCategory.php b/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValueCategory.php index 37ca846119..bb3b72d79f 100644 --- a/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValueCategory.php +++ b/Updated_Cms/app/Models/Community/RareValue/WebsiteRareValueCategory.php @@ -9,6 +9,9 @@ class WebsiteRareValueCategory extends Model { protected $guarded = ['id', 'created_at', 'updated_at']; + /** + * @return HasMany + */ public function furniture(): HasMany { return $this->hasMany(WebsiteRareValue::class, 'category_id'); diff --git a/Updated_Cms/app/Models/Community/Staff/WebsiteStaffApplications.php b/Updated_Cms/app/Models/Community/Staff/WebsiteStaffApplications.php index e6b766875e..75c88f714d 100644 --- a/Updated_Cms/app/Models/Community/Staff/WebsiteStaffApplications.php +++ b/Updated_Cms/app/Models/Community/Staff/WebsiteStaffApplications.php @@ -19,11 +19,17 @@ class WebsiteStaffApplications extends Model 'content', ]; + /** + * @return BelongsTo + */ public function rank(): BelongsTo { return $this->belongsTo(Permission::class, 'rank_id'); } + /** + * @return BelongsTo + */ public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id');