Skip to content

Commit

Permalink
fix: replace dates with Eloquent's casts
Browse files Browse the repository at this point in the history
Replaces $dates, which have been deprecated for some time, with $casts.
In Laravel 10, $dates are gone, making this a necessary fix.
  • Loading branch information
thor committed Sep 28, 2023
1 parent dc66461 commit 7229da7
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/Models/ActivityLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ActivityLog extends Model
{
public $timestamps = false;

protected $dates = [
'created_at',
protected $casts = [
'created_at' => 'datetime',
];

public function user()
Expand Down
8 changes: 4 additions & 4 deletions app/Models/AtcActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class AtcActivity extends Model

protected $fillable = ['user_id', 'hours', 'start_of_grace_period'];

protected $dates = [
'created_at',
'updated_at',
'start_of_grace_period',
protected $casts = [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'start_of_grace_period' => 'datetime',
];

public function user()
Expand Down
10 changes: 5 additions & 5 deletions app/Models/Endorsement.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Endorsement extends Model
{
use HasFactory;

protected $dates = [
'valid_from',
'valid_to',
'created_at',
'updated_at',
protected $casts = [
'valid_from' => 'datetime',
'valid_to' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

public function ratings()
Expand Down
8 changes: 4 additions & 4 deletions app/Models/OneTimeLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class OneTimeLink extends Model

public $timestamps = false;

protected $dates = [
'expires_at',
protected $casts = [
'expires_at' => 'datetime',
];

/**
Expand Down Expand Up @@ -45,7 +45,7 @@ public function getLink()
*/
public function reportType()
{
return self::TRAINING_REPORT_TYPE == $this->training_object_type;
return $this->training_object_type == self::TRAINING_REPORT_TYPE;
}

/**
Expand All @@ -55,7 +55,7 @@ public function reportType()
*/
public function examinationType()
{
return self::TRAINING_EXAMINATION_TYPE == $this->training_object_type;
return $this->training_object_type == self::TRAINING_EXAMINATION_TYPE;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Training.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class Training extends Model

protected $table = 'trainings';

protected $dates = [
'started_at',
'closed_at',
protected $casts = [
'started_at' => 'datetime',
'closed_at' => 'datetime',
];

/**
Expand Down
3 changes: 1 addition & 2 deletions app/Models/TrainingExamination.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class TrainingExamination extends TrainingObject

protected $guarded = [];

protected $dates = ['examination_date'];

protected $casts = [
'draft' => 'boolean',
'examination_date' => 'datetime',
];

public function position()
Expand Down
6 changes: 3 additions & 3 deletions app/Models/TrainingInterest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class TrainingInterest extends Model
{
protected $guarded = [];

protected $dates = [
'deadline',
'confirmed_at',
protected $casts = [
'deadline' => 'datetime',
'confirmed_at' => 'datetime',
];

public function training()
Expand Down
3 changes: 1 addition & 2 deletions app/Models/TrainingReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class TrainingReport extends TrainingObject

protected $guarded = [];

protected $dates = ['report_date'];

protected $casts = [
'draft' => 'boolean',
'report_date' => 'datetime',
];

public function path()
Expand Down
8 changes: 4 additions & 4 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class User extends Authenticatable

public $timestamps = false;

protected $dates = [
'last_login',
'last_activity',
'last_inactivity_warning',
protected $casts = [
'last_login' => 'datetime',
'last_activity' => 'datetime',
'last_inactivity_warning' => 'datetime',
];

/**
Expand Down

0 comments on commit 7229da7

Please sign in to comment.