mirror of
https://github.com/flarum/core.git
synced 2025-07-23 09:41:26 +02:00
API: allow date attributes to be added
This commit is contained in:
@@ -32,6 +32,11 @@ class Model implements ExtenderInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function date($attribute)
|
||||
{
|
||||
$this->dates[] = $attribute;
|
||||
}
|
||||
|
||||
public function hasOne($relation, $related, $foreignKey = null, $localKey = null)
|
||||
{
|
||||
$this->relations[$relation] = function ($model) use ($relation, $related, $foreignKey, $localKey) {
|
||||
@@ -73,7 +78,7 @@ class Model implements ExtenderInterface
|
||||
$model = $this->model;
|
||||
|
||||
foreach ($this->relations as $relation => $callback) {
|
||||
$model::addRelationship($relation, $callback);
|
||||
$model::setRelationMethod($relation, $callback);
|
||||
}
|
||||
|
||||
foreach ($this->scopeVisible as $callback) {
|
||||
@@ -83,5 +88,9 @@ class Model implements ExtenderInterface
|
||||
foreach ($this->allow as $info) {
|
||||
$model::allow($info['action'], $info['callback']);
|
||||
}
|
||||
|
||||
foreach ($this->dates as $attribute) {
|
||||
$model::addDate($attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user