first commit
This commit is contained in:
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
44
database/factories/UserFactory.php
Normal file
44
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
51
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
51
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('login')->unique();
|
||||
$table->string('password');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedBigInteger('rf_lpudoctor_id')->nullable();
|
||||
$table->foreignIdFor(\App\Models\Department::class, 'rf_department_id');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('login')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('metrika_items', function (Blueprint $table) {
|
||||
$table->id('metrika_item_id')
|
||||
->comment('Идентификатор метрики');
|
||||
$table->string('name')
|
||||
->comment('Наименование метрики');
|
||||
$table->text('description')
|
||||
->nullable()
|
||||
->comment('Описание метрики');
|
||||
$table->string('data_type')
|
||||
->default('integer')
|
||||
->comment('Тип значения для метрики');
|
||||
$table->boolean('is_active')
|
||||
->default(true)
|
||||
->comment('Активна ли метрика');
|
||||
$table->json('validation_rules')
|
||||
->nullable()
|
||||
->comment('Правила валидации для фронтенда');
|
||||
$table->string('default_value')
|
||||
->nullable()
|
||||
->comment('Значение по умолчанию для фронтенда');
|
||||
$table->boolean('is_required')
|
||||
->default(false)
|
||||
->comment('Обязательный ввод для фронтенда');
|
||||
$table->json('options')
|
||||
->nullable()
|
||||
->comment('Опции выбора для фронтенда (select)');
|
||||
$table->string('placeholder')
|
||||
->nullable()
|
||||
->comment('Подсказка ввода для фронтенда');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('metrika_items');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('metrika_groups', function (Blueprint $table) {
|
||||
$table->id('metrika_group_id')
|
||||
->comment('Идентификатор группы метрик');
|
||||
$table->string('name')
|
||||
->comment('Наименование группы метрик');
|
||||
$table->text('description')
|
||||
->nullable()
|
||||
->comment('Описание группы метрик');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('metrika_groups');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('metrika_group_items', function (Blueprint $table) {
|
||||
$table->id('metrika_group_item_id');
|
||||
$table->foreignIdFor( \App\Models\MetrikaGroup::class, 'rf_metrika_group_id')
|
||||
->comment('Идентификатор группы метрик')
|
||||
->constrained()
|
||||
->cascadeOnDelete();
|
||||
$table->foreignIdFor(\App\Models\MetrikaItem::class, 'rf_metrika_item_id')
|
||||
->comment('Идентификатор метрики')
|
||||
->constrained()
|
||||
->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('metrika_group_items');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('reports', function (Blueprint $table) {
|
||||
$table->id('report_id');
|
||||
$table->date('created_at');
|
||||
$table->date('sent_at')->nullable();
|
||||
$table->foreignIdFor(\App\Models\Department::class, 'rf_department_id')->default(1);
|
||||
$table->foreignIdFor(\App\Models\User::class, 'rf_user_id')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('reports');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('metrika_results', function (Blueprint $table) {
|
||||
$table->id('metrika_result_id')
|
||||
->comment('Идентификатор результата метрики');
|
||||
$table->foreignIdFor(\App\Models\Report::class, 'rf_report_id')
|
||||
->comment('Идентификатор отчета')
|
||||
->constrained()
|
||||
->cascadeOnDelete();
|
||||
$table->foreignIdFor(\App\Models\MetrikaGroup::class, 'rf_metrika_group_id')
|
||||
->comment('Идентификатор группы метрики')
|
||||
->constrained();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('metrika_results');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('metrika_result_values', function (Blueprint $table) {
|
||||
$table->id('metrika_result_value_id')
|
||||
->comment('Идентификатор результата метрики');
|
||||
$table->foreignIdFor(\App\Models\MetrikaResult::class, 'rf_metrika_result_id')
|
||||
->comment('Идентификатор результата метрики')
|
||||
->constrained()
|
||||
->cascadeOnDelete();
|
||||
$table->foreignIdFor(\App\Models\MetrikaItem::class, 'rf_metrika_item_id')
|
||||
->comment('Идентификатор метрики')
|
||||
->constrained();
|
||||
$table->text('value');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('metrika_result_values');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->text('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
24
database/seeders/DatabaseSeeder.php
Normal file
24
database/seeders/DatabaseSeeder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
TestLpuDataSeeder::class,
|
||||
TestMetrikaSeeder::class,
|
||||
TestUserSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
46
database/seeders/TestLpuDataSeeder.php
Normal file
46
database/seeders/TestLpuDataSeeder.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class TestLpuDataSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Schema::create('oms_lpu', function (Blueprint $table) {
|
||||
$table->id('lpuid');
|
||||
$table->string('mname_s');
|
||||
$table->foreignId('mainlpuid')->nullable()->constrained('oms_lpu', 'lpuid');
|
||||
});
|
||||
Schema::create('oms_department', function (Blueprint $table) {
|
||||
$table->id('depatmentid');
|
||||
$table->string('departmentname');
|
||||
$table->foreignId('rf_lpuid')->constrained('oms_lpu', 'lpuid');
|
||||
});
|
||||
|
||||
\DB::table('oms_lpu')->insert([
|
||||
'lpuid' => 1,
|
||||
'mname_s' => 'ГАУЗ АО АОКБ',
|
||||
'mainlpuid' => null
|
||||
]);
|
||||
\DB::table('oms_lpu')->insert([
|
||||
'lpuid' => 2,
|
||||
'mname_s' => 'Приемное отделение',
|
||||
'mainlpuid' => 1
|
||||
]);
|
||||
|
||||
|
||||
\DB::table('oms_department')->insert([
|
||||
'departmentname' => 'Тест',
|
||||
'rf_lpuid' => 2,
|
||||
'depatmentid' => 1
|
||||
]);
|
||||
}
|
||||
}
|
||||
54
database/seeders/TestMetrikaSeeder.php
Normal file
54
database/seeders/TestMetrikaSeeder.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\MetrikaGroup;
|
||||
use App\Models\MetrikaGroupItem;
|
||||
use App\Models\MetrikaItem;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TestMetrikaSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
MetrikaItem::create([
|
||||
'name' => 'Коек',
|
||||
'data_type' => 'integer'
|
||||
]);
|
||||
MetrikaItem::create([
|
||||
'name' => 'Состояло',
|
||||
'data_type' => 'integer'
|
||||
]);
|
||||
MetrikaItem::create([
|
||||
'name' => 'Поступило',
|
||||
'data_type' => 'integer'
|
||||
]);
|
||||
MetrikaItem::create([
|
||||
'name' => 'План',
|
||||
'data_type' => 'integer'
|
||||
]);
|
||||
MetrikaItem::create([
|
||||
'name' => 'Самотек',
|
||||
'data_type' => 'integer'
|
||||
]);
|
||||
MetrikaItem::create([
|
||||
'name' => 'Скорая',
|
||||
'data_type' => 'integer'
|
||||
]);
|
||||
|
||||
MetrikaGroup::create([
|
||||
'name' => 'Сводная',
|
||||
]);
|
||||
|
||||
foreach (MetrikaItem::all() as $item) {
|
||||
MetrikaGroupItem::create([
|
||||
'rf_metrika_group_id' => 1,
|
||||
'rf_metrika_item_id' => $item->metrika_item_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
database/seeders/TestUserSeeder.php
Normal file
24
database/seeders/TestUserSeeder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TestUserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
User::create([
|
||||
'name' => 'Test User',
|
||||
'login' => 'test',
|
||||
'password' => \Hash::make('test'),
|
||||
'rf_department_id' => 1,
|
||||
'rf_lpudoctor_id' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user