Skip to content

Commit

Permalink
replace cast proparty with cast method
Browse files Browse the repository at this point in the history
  • Loading branch information
hamoda-dev committed Apr 2, 2024
1 parent dfd0f77 commit 5c46055
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 8 additions & 5 deletions app/Models/Challenge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -56,4 +51,12 @@ public function comments()
{
return $this->morphMany(Comment::class, 'commentable');
}

protected function casts(): array
{
return [
'created_at' => 'datetime',
'continued_at' => 'datetime',
];
}
}
11 changes: 7 additions & 4 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class User extends Authenticatable
'password',
];

protected $casts = [
'email_verified_at' => 'datetime',
];

protected $with = ['country'];

public function isFollowedBy($userId): bool
Expand Down Expand Up @@ -53,4 +49,11 @@ public function achievements()
{
return $this->hasMany(UserAchievement::class);
}

protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
];
}
}

0 comments on commit 5c46055

Please sign in to comment.