From 52e55bd5036f0f24f33e9ef6ec232874d516941b Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Wed, 1 Jul 2015 16:47:07 +0930 Subject: [PATCH] Cleanup, fix static date property error --- framework/core/src/Core/Models/Discussion.php | 2 +- .../core/src/Core/Models/DiscussionState.php | 23 ++++++++++++++----- framework/core/src/Core/Models/Model.php | 10 ++++---- framework/core/src/Extend/Model.php | 2 +- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/framework/core/src/Core/Models/Discussion.php b/framework/core/src/Core/Models/Discussion.php index 385a82edf..6dc133146 100755 --- a/framework/core/src/Core/Models/Discussion.php +++ b/framework/core/src/Core/Models/Discussion.php @@ -45,7 +45,7 @@ class Discussion extends Model * * @var array */ - protected static $dates = ['start_time', 'last_time']; + protected static $dateAttributes = ['start_time', 'last_time']; /** * The user for which the state relationship should be loaded. diff --git a/framework/core/src/Core/Models/DiscussionState.php b/framework/core/src/Core/Models/DiscussionState.php index 971396649..52d6c0045 100644 --- a/framework/core/src/Core/Models/DiscussionState.php +++ b/framework/core/src/Core/Models/DiscussionState.php @@ -1,9 +1,20 @@ where('discussion_id', $this->discussion_id) ->where('user_id', $this->user_id); diff --git a/framework/core/src/Core/Models/Model.php b/framework/core/src/Core/Models/Model.php index e3964d162..6350ca969 100755 --- a/framework/core/src/Core/Models/Model.php +++ b/framework/core/src/Core/Models/Model.php @@ -35,14 +35,14 @@ abstract class Model extends Eloquent * * @var array */ - public static $dates = []; + protected static $dateAttributes = []; /** * The validation rules for this model. * * @var array */ - protected static $rules = []; + public static $rules = []; /** * An array of custom relation methods, grouped by subclass. @@ -176,7 +176,7 @@ abstract class Model extends Eloquent */ public function getDates() { - return static::$dates; + return array_merge(static::$dateAttributes, $this->dates); } /** @@ -184,9 +184,9 @@ abstract class Model extends Eloquent * * @param string $attribute */ - public static function addDate($attribute) + public static function addDateAttribute($attribute) { - static::$dates[] = $attribute; + static::$dateAttributes[] = $attribute; } /** diff --git a/framework/core/src/Extend/Model.php b/framework/core/src/Extend/Model.php index 4b8695a34..d7fe120e5 100644 --- a/framework/core/src/Extend/Model.php +++ b/framework/core/src/Extend/Model.php @@ -90,7 +90,7 @@ class Model implements ExtenderInterface } foreach ($this->dates as $attribute) { - $model::addDate($attribute); + $model::addDateAttribute($attribute); } } }