migration appointment & seeder

This commit is contained in:
Muhammad Fajar
2022-11-04 09:54:08 +07:00
parent 975f6cec35
commit 4b4104bc6b
5 changed files with 181 additions and 0 deletions

View File

@@ -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.
*
* @return void
*/
public function up()
{
Schema::create('appointment_types', function (Blueprint $table) {
$table->id();
$table->string('code');
$table->string('name');
$table->string('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('appointment_types');
}
};

View File

@@ -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('appointments', function (Blueprint $table) {
$table->id();
$table->string('status');
$table->string('cancelation_reason');
$table->string('appointment_type');
$table->string('description');
$table->string('duration_minutes');
$table->string('start_time');
$table->string('end_time');
$table->text('comment');
$table->text('patient_instruction');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('appointments');
}
};

View File

@@ -0,0 +1,35 @@
<?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('appointment_participants', function (Blueprint $table) {
$table->id();
$table->string('type');
$table->string('participantable_type');
$table->string('participantable_id');
$table->string('status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('appointment_participants');
}
};

View File

@@ -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::table('appointments', function (Blueprint $table) {
$table->foreignId('speciality_id')->nullable()->after('appointment_type');
$table->foreignId('organization_id')->nullable()->after('end_time');
});
Schema::table('appointment_participants', function (Blueprint $table) {
$table->foreignId('appointment_id')->nullable()->after('id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('appointments', function (Blueprint $table) {
$table->dropColumn('speciality_id');
$table->dropColumn('organization_id');
});
Schema::table('appointment_participants', function (Blueprint $table) {
$table->dropColumn('appointment_id');
});
}
};

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AppointmentTypesSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$codes = ['ROUTINE', 'WALKIN', 'CHECKUP', 'FOLLOWUP', 'EMERGENCY', 'TELECONSULTATION'];
$names = ['Routine', 'Walk In', 'Check-Up', 'Follow Up', 'Emergency', 'Teleconsultation'];
$descriptions = ['Routine Appointment', 'A previously unscheduled walk-in visit', 'A routine check-up, such as an annual physical', 'A follow up visit from a previous appointment', 'Emergency appointment', 'Teleconsultation appointment'];
for ($i = 0; $i < count($codes); $i++) {
DB::table('appointment_types')->insert([
'code' => $codes[$i],
'name' => $names[$i],
'description' => $descriptions[$i]
]);
}
}
}