28 lines
605 B
PHP
28 lines
605 B
PHP
<?php namespace Lucent\Core\Repository;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Lucent\Core\Schema\Data\Schema;
|
|
use Lucent\Core\Schema\SchemaModule;
|
|
|
|
class SchemaRepo
|
|
{
|
|
const TABLE_NAME = "schemas";
|
|
|
|
/**
|
|
* @@return Schema[]
|
|
*/
|
|
public static function all(): array
|
|
{
|
|
return DB::table(self::TABLE_NAME)
|
|
->orderBy("name")
|
|
->get()
|
|
->map(SchemaModule::fromDb(...))
|
|
->toArray();
|
|
}
|
|
|
|
public static function insert(Schema $schema): void
|
|
{
|
|
DB::table(self::TABLE_NAME)->insert(SchemaModule::toDb($schema));
|
|
}
|
|
}
|