mirror of
https://github.com/flarum/core.git
synced 2025-07-07 10:04:44 +02:00
Not sure how these got in here...
This commit is contained in:
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php namespace Flarum\Core\Models;
|
|
||||||
|
|
||||||
interface MergeableInterface
|
|
||||||
{
|
|
||||||
public function saveAfter(Model $previous);
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
Reference in New Issue
Block a user