mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Not sure how these got in here...
This commit is contained in:
parent
09d1c4d8ed
commit
2cd279176d
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user