field create
This commit is contained in:
@@ -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")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user