1
0
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:
Toby Zerner
2015-07-01 15:11:57 +09:30
parent 894349e9c5
commit a4dc7ff121
3 changed files with 40 additions and 4 deletions

View File

@@ -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);
}
}
}