Not sure how these got in here...

This commit is contained in:
Toby Zerner 2015-07-01 22:47:57 +09:30
parent 09d1c4d8ed
commit 2cd279176d
3 changed files with 0 additions and 56 deletions

View File

@ -1,27 +0,0 @@
<?php namespace Flarum\Core\Models;
abstract class EventPost extends Post implements MergeableInterface
{
use MergeableTrait;
/**
* Unserialize the content attribute.
*
* @param string $value
* @return string
*/
public function getContentAttribute($value)
{
return json_decode($value, true);
}
/**
* Serialize the content attribute.
*
* @param string $value
*/
public function setContentAttribute($value)
{
$this->attributes['content'] = json_encode($value);
}
}

View File

@ -1,6 +0,0 @@
<?php namespace Flarum\Core\Models;
interface MergeableInterface
{
public function saveAfter(Model $previous);
}

View File

@ -1,23 +0,0 @@
<?php namespace Flarum\Core\Models;
trait MergeableTrait
{
public function saveAfter(Model $previous)
{
if ($previous instanceof static) {
if ($merged = $this->mergeInto($previous)) {
$merged->save();
return $merged;
} else {
$previous->delete();
return $previous;
}
}
$this->save();
return $this;
}
abstract protected function mergeInto(Model $previous);
}