field create
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php namespace Lucent\Core\Repository;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Core\Schema\Data\Field;
|
||||
use Lucent\Core\Schema\FieldModule;
|
||||
use Lucent\Core\Schema\SchemaModule;
|
||||
|
||||
class FieldRepo
|
||||
{
|
||||
const TABLE_NAME = "fields";
|
||||
|
||||
/**
|
||||
* @@return Field[]
|
||||
*/
|
||||
public static function all(): array
|
||||
{
|
||||
return DB::table(self::TABLE_NAME)
|
||||
->orderBy("name")
|
||||
->get()
|
||||
->map(SchemaModule::fromDb(...))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public static function insert(Field $field): void
|
||||
{
|
||||
DB::table(self::TABLE_NAME)->insert(FieldModule::toDb($field));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user