From 5c4605516312d082873c38d30555f06eb00433c7 Mon Sep 17 00:00:00 2001 From: Mohammed Hamid Hamoda Date: Tue, 2 Apr 2024 13:47:16 +0200 Subject: [PATCH] replace cast proparty with cast method --- app/Models/Challenge.php | 13 ++++++++----- app/Models/User.php | 11 +++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Models/Challenge.php b/app/Models/Challenge.php index 84d216c..870c6f1 100644 --- a/app/Models/Challenge.php +++ b/app/Models/Challenge.php @@ -14,11 +14,6 @@ class Challenge extends Model protected $with = ['user']; - protected $casts = [ - 'created_at' => 'datetime', - 'continued_at' => 'datetime', - ]; - public function scopeByUserId(Builder $query, $userId = null): void { if ($userId !== null) { @@ -56,4 +51,12 @@ public function comments() { return $this->morphMany(Comment::class, 'commentable'); } + + protected function casts(): array + { + return [ + 'created_at' => 'datetime', + 'continued_at' => 'datetime', + ]; + } } diff --git a/app/Models/User.php b/app/Models/User.php index 8f7b5f3..25b3ced 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -20,10 +20,6 @@ class User extends Authenticatable 'password', ]; - protected $casts = [ - 'email_verified_at' => 'datetime', - ]; - protected $with = ['country']; public function isFollowedBy($userId): bool @@ -53,4 +49,11 @@ public function achievements() { return $this->hasMany(UserAchievement::class); } + + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + ]; + } }