This commit is contained in:
2023-03-30 20:39:00 +08:00
parent bfa39c3669
commit 5c9f92f955
6 changed files with 275 additions and 167 deletions
+4 -2
View File
@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace Database;
use Database\Base\Getter;
use Exception;
use Kiri;
use Kiri\Exception\NotFindClassException;
@@ -264,8 +265,9 @@ class Model extends Base\Model
public function toArray(): array
{
$data = $this->_attributes;
foreach ($data as $key => $datum) {
$data[$key] = $this->withPropertyOverride($key, $datum);
$keys = Kiri::getDi()->get(Getter::class);
foreach ($keys->getAll(static::class) as $key => $datum) {
$data[$key] = $this->{$datum}($data[$key]);
}
return $this->withRelates($data);
}