edit schema wip
This commit is contained in:
@@ -10,19 +10,40 @@ class FieldRepo
|
||||
const TABLE_NAME = "fields";
|
||||
|
||||
/**
|
||||
* @@return Field[]
|
||||
* @return Field[]
|
||||
*/
|
||||
public static function all(): array
|
||||
{
|
||||
return DB::table(self::TABLE_NAME)
|
||||
->orderBy("name")
|
||||
->orderBy("rank")
|
||||
->get()
|
||||
->map(SchemaModule::fromDb(...))
|
||||
->map(FieldModule::fromDb(...))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public static function findOne(string $id): ?Field
|
||||
{
|
||||
return DB::table(self::TABLE_NAME)
|
||||
->where("id", $id)
|
||||
->get()
|
||||
->map(FieldModule::fromDb(...))
|
||||
->first();
|
||||
}
|
||||
|
||||
public static function insert(Field $field): void
|
||||
{
|
||||
DB::table(self::TABLE_NAME)->insert(FieldModule::toDb($field));
|
||||
}
|
||||
|
||||
public static function update(Field $field): void
|
||||
{
|
||||
DB::table(self::TABLE_NAME)
|
||||
->where("id", $field->id)
|
||||
->update(FieldModule::toDb($field));
|
||||
}
|
||||
|
||||
public static function delete(string $fieldId): void
|
||||
{
|
||||
DB::table(self::TABLE_NAME)->where("id", $fieldId)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,15 @@ class SchemaRepo
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public static function findOne(string $id): ?Schema
|
||||
{
|
||||
return DB::table(self::TABLE_NAME)
|
||||
->where("id", $id)
|
||||
->get()
|
||||
->map(SchemaModule::fromDb(...))
|
||||
->first();
|
||||
}
|
||||
|
||||
public static function insert(Schema $schema): void
|
||||
{
|
||||
DB::table(self::TABLE_NAME)->insert(SchemaModule::toDb($schema));
|
||||
|
||||
Reference in New Issue
Block a user