25 lines
442 B
PHP
25 lines
442 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
trait HasMeta
|
|
{
|
|
public function getMeta(): object
|
|
{
|
|
return (object) $this->meta;
|
|
}
|
|
|
|
public final function updateMetaKey($key, $value, bool $update = true): self
|
|
{
|
|
$meta = $this->getMeta();
|
|
$meta->{$key} = $value;
|
|
$this->meta = (object) $meta;
|
|
|
|
if ($update) {
|
|
$this->update(['meta' => $this->meta]);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|