52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Providers\AppServiceProvider;
|
|
use Src\Modules\JsonObjects\Interfaces\IFactory;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('json_dirs', function(Blueprint $table){
|
|
$table->string('id')->primary();
|
|
$table->string('matherial_path');
|
|
$table->string('parent_id');
|
|
$table->string('name');
|
|
});
|
|
|
|
Schema::create('json_items', function(Blueprint $table){
|
|
$table->string('id')->primary();
|
|
$table->string('dir_id');
|
|
$table->string('key');
|
|
$table->string('name');
|
|
$table->string('description')->nullable();
|
|
$table->json('object');
|
|
$table->integer('disabled', false, true)->default(0);
|
|
});
|
|
|
|
/** @var IFactory */
|
|
$factory = app(AppServiceProvider::ADMIN_MODULES)->getJsonObjectsFactory();
|
|
$item = $factory->getDtoFactory()->getItemFactory()->createPersist(\Src\Common\Dto\Object\ExampleComposit::EXAMPLE_COMPOSIT);
|
|
$item->load(['key' => 'key', 'name' => 'name']);
|
|
|
|
$attrs = $item->getInsertAttrs();
|
|
DB::table('json_items')->insert($attrs);
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('admins');
|
|
}
|
|
};
|