mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Cleanup, fix static date property error
This commit is contained in:
parent
009b479197
commit
52e55bd503
|
@ -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.
|
||||
|
|
|
@ -1,9 +1,20 @@
|
|||
<?php namespace Flarum\Core\Models;
|
||||
|
||||
use Flarum\Core\Events\DiscussionWasRead;
|
||||
use Flarum\Core\Support\EventGenerator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* Models a discussion-user state record in the database.
|
||||
*
|
||||
* Stores information about how much of a discussion a user has read. Can also
|
||||
* be used to store other information, if the appropriate columns are added to
|
||||
* the database, like a user's subscription status for a discussion.
|
||||
*/
|
||||
class DiscussionState extends Model
|
||||
{
|
||||
use EventGenerator;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -16,13 +27,13 @@ class DiscussionState extends Model
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['read_time'];
|
||||
protected static $dateAttributes = ['read_time'];
|
||||
|
||||
/**
|
||||
* Mark the discussion as read to a certain point by updating that state's
|
||||
* data.
|
||||
* Mark the discussion as being read up to a certain point. Raises the
|
||||
* DiscussionWasRead event.
|
||||
*
|
||||
* @param int $number
|
||||
* @param int $number
|
||||
* @return $this
|
||||
*/
|
||||
public function read($number)
|
||||
|
@ -60,10 +71,10 @@ class DiscussionState extends Model
|
|||
/**
|
||||
* Set the keys for a save update query.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function setKeysForSaveQuery(\Illuminate\Database\Eloquent\Builder $query)
|
||||
protected function setKeysForSaveQuery(Builder $query)
|
||||
{
|
||||
$query->where('discussion_id', $this->discussion_id)
|
||||
->where('user_id', $this->user_id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -90,7 +90,7 @@ class Model implements ExtenderInterface
|
|||
}
|
||||
|
||||
foreach ($this->dates as $attribute) {
|
||||
$model::addDate($attribute);
|
||||
$model::addDateAttribute($attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user