field create

This commit is contained in:
2026-01-08 13:10:18 +02:00
parent 4d2497d96f
commit ebccac210a
15 changed files with 318 additions and 18 deletions
+25 -9
View File
@@ -1,18 +1,20 @@
<?php namespace Lucent\Core\Schema;
use Lucent\Core\Schema\Data\Field;
use Lucent\Core\Schema\Data\FieldProp\FieldProp;
use stdClass;
class FieldModule
{
public static function fromArray(array $data): Field
{
return new Field(
id: $data["id"],
alias: $data["alias"],
name: $data["name"],
type: $data["type"],
);
}
// public static function fromArray(array $data): Field
// {
// return new Field(
// id: $data["id"],
// alias: $data["alias"],
// name: $data["name"],
// type: $data["type"],
// );
// }
public static function toDb(Field $field): array
{
@@ -21,6 +23,20 @@ class FieldModule
"alias" => $field->alias,
"name" => $field->name,
"type" => $field->type,
"props" => json_encode($field->props),
"schema_id" => $field->schemaId,
];
}
public static function fromDb(stdClass $data): Field
{
return new Field(
id: data_get($data, "id"),
alias: data_get($data, "alias"),
name: data_get($data, "name"),
type: data_get($data, "type"),
schemaId: data_get($data, "schema_id"),
props: FieldProp::fromDb(data_get($data, "props")),
);
}
}