laravel-workkit/src/Traits/HasMeta.php

25 lines
442 B
PHP
Raw Normal View History

2025-11-20 14:53:34 +00:00
<?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;
}
}