Skip to content

Commit

Permalink
Switch from method to property for dates
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Dec 29, 2015
1 parent 077f3e9 commit 26096e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
16 changes: 7 additions & 9 deletions src/Auth/Models/Throttle.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class Throttle extends Model
*/
public $timestamps = false;

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['last_attempt_at', 'suspended_at', 'banned_at'];

/**
* @var int Attempt limit.
*/
Expand Down Expand Up @@ -254,13 +261,4 @@ public function getIsBannedAttribute($banned)
{
return (bool) $banned;
}

/**
* Get the attributes that should be converted to dates.
* @return array
*/
public function getDates()
{
return array_merge(parent::getDates(), ['last_attempt_at', 'suspended_at', 'banned_at']);
}
}
18 changes: 8 additions & 10 deletions src/Auth/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class User extends Model
'groups' => ['October\Rain\Auth\Models\Group', 'table' => 'users_groups']
];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['activated_at', 'last_login'];

/**
* @var array The attributes that should be hidden for arrays.
*/
Expand Down Expand Up @@ -645,13 +652,4 @@ public function getRandomString($length = 42)

return substr(str_shuffle(str_repeat($pool, 5)), 0, $length);
}

/**
* Get the attributes that should be converted to dates.
* @return array
*/
public function getDates()
{
return array_merge(parent::getDates(), ['activated_at', 'last_login']);
}
}
}

0 comments on commit 26096e5

Please sign in to comment.