Add Service Config
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('corporate_services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('corporate_id')->index();
|
||||
$table->string('service_code')->index();
|
||||
$table->string('status')->default('active');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
|
||||
$table->index(['corporate_id', 'service_code']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('corporate_services');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('corporate_service_configs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('corporate_service_id')->index();
|
||||
$table->string('name');
|
||||
$table->text('value');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('corporate_service_configs');
|
||||
}
|
||||
};
|
||||
129
database/seeders/ServiceSeeder.php
Normal file
129
database/seeders/ServiceSeeder.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Corporate;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ServiceSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$services = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'Out Patient',
|
||||
'code' => 'OP',
|
||||
'description' => 'Out Patient',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'Inpatient',
|
||||
'code' => 'IP',
|
||||
'description' => 'Inpatient',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => 'Dental',
|
||||
'code' => 'DE',
|
||||
'description' => 'Dental',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => 'Maternal',
|
||||
'code' => 'MA',
|
||||
'description' => 'Maternal',
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => 'Optical',
|
||||
'code' => 'OPT',
|
||||
'description' => 'Optical',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$corporates = Corporate::get();
|
||||
|
||||
foreach ($services as $service) {
|
||||
$service = Service::updateOrCreate(['id' => $service['id']], $service);
|
||||
|
||||
foreach ($corporates as $corporate) {
|
||||
$corporateService = $corporate->corporateServices()->create([
|
||||
'service_code' => $service->code,
|
||||
'status' => 'active'
|
||||
]);
|
||||
|
||||
$corporateService->configs()->insert([
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_external_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_external_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_internal_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_internal_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_external_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_external_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_internal_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_internal_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'vitamins',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'delivery_fee',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'general_practitioner_fee',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'specialist_practitioner_fee',
|
||||
'value' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user