Update Doctor Resource
This commit is contained in:
@@ -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('practices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('practitioner_role_id');
|
||||
$table->string('service_code');
|
||||
$table->boolean('active')->default(1);
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreignId('created_by')->nullable()->index();
|
||||
$table->foreignId('updated_by')->nullable()->index();
|
||||
$table->foreignId('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('practices');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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('prices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('priceable');
|
||||
$table->foreignId('price_group_id');
|
||||
$table->string('price_gross');
|
||||
$table->string('price_net');
|
||||
$table->boolean('has_tax');
|
||||
$table->string('discount_type');
|
||||
$table->string('discount_percentage');
|
||||
$table->string('discount_absolute');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreignId('created_by')->nullable()->index();
|
||||
$table->foreignId('updated_by')->nullable()->index();
|
||||
$table->foreignId('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('prices');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('practitioner_role_availabilities', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('practitioner_role_id');
|
||||
$table->boolean('all_day');
|
||||
$table->time('start_time')->nullable();
|
||||
$table->time('end_time')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreignId('created_by')->nullable()->index();
|
||||
$table->foreignId('updated_by')->nullable()->index();
|
||||
$table->foreignId('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('practitioner_role_availabilities');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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('practitioner_role_availability_days', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('availability_id');
|
||||
$table->string('day');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreignId('created_by')->nullable()->index();
|
||||
$table->foreignId('updated_by')->nullable()->index();
|
||||
$table->foreignId('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('practitioner_role_availability_days');
|
||||
}
|
||||
};
|
||||
@@ -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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('provinces', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('provinces');
|
||||
}
|
||||
};
|
||||
@@ -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('cities', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('province_id');
|
||||
$table->string('name');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cities');
|
||||
}
|
||||
};
|
||||
@@ -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('districts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('city_id');
|
||||
$table->string('name');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('districts');
|
||||
}
|
||||
};
|
||||
@@ -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('villages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('district_id');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('villages');
|
||||
}
|
||||
};
|
||||
54
database/seeders/CitySeeder.php
Normal file
54
database/seeders/CitySeeder.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\City;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CitySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
City::truncate();
|
||||
|
||||
$chunks = [];
|
||||
$time = now();
|
||||
if (($handle = fopen(resource_path('files/city.csv'), "r")) !== FALSE) {
|
||||
$firstline = true;
|
||||
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
|
||||
if (!$firstline) {
|
||||
$d = explode(';', $data[0]);
|
||||
|
||||
$row = [
|
||||
"id" => $d[0],
|
||||
"province_id" => $d[1],
|
||||
"name" => ucwords(strtolower($d[2])),
|
||||
"created_at" => $time,
|
||||
"updated_at" => $time
|
||||
];
|
||||
|
||||
$chunks[] = $row;
|
||||
}
|
||||
$firstline = false;
|
||||
|
||||
if ($chunks && count($chunks) == 100) {
|
||||
City::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
}
|
||||
|
||||
if ($chunks && count($chunks) > 0) {
|
||||
City::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ class DatabaseSeeder extends Seeder
|
||||
IcdSeeder::class,
|
||||
ServiceSeeder::class,
|
||||
SpecialitiesSeeder::class,
|
||||
ProvinceSeeder::class,
|
||||
CitySeeder::class,
|
||||
DistrictSeeder::class,
|
||||
VillageSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
54
database/seeders/DistrictSeeder.php
Normal file
54
database/seeders/DistrictSeeder.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\District;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DistrictSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
District::truncate();
|
||||
|
||||
$chunks = [];
|
||||
$time = now();
|
||||
if (($handle = fopen(resource_path('files/district.csv'), "r")) !== FALSE) {
|
||||
$firstline = true;
|
||||
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
|
||||
if (!$firstline) {
|
||||
$d = explode(';', $data[0]);
|
||||
|
||||
$row = [
|
||||
"id" => $d[0],
|
||||
"city_id" => $d[1],
|
||||
"name" => ucwords(strtolower($d[2])),
|
||||
"created_at" => $time,
|
||||
"updated_at" => $time
|
||||
];
|
||||
|
||||
$chunks[] = $row;
|
||||
}
|
||||
$firstline = false;
|
||||
|
||||
if ($chunks && count($chunks) == 100) {
|
||||
District::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
}
|
||||
|
||||
if ($chunks && count($chunks) > 0) {
|
||||
District::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
86
database/seeders/PractitionerRoleDummySeeder.php
Normal file
86
database/seeders/PractitionerRoleDummySeeder.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Practice;
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PractitionerRoleDummySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Practice::truncate();
|
||||
|
||||
$times = [
|
||||
'07:00:00',
|
||||
'07:30:00',
|
||||
'08:00:00',
|
||||
'08:30:00',
|
||||
'09:00:00',
|
||||
'09:30:00',
|
||||
'10:00:00',
|
||||
'10:30:00',
|
||||
'11:00:00',
|
||||
'11:30:00',
|
||||
'12:00:00',
|
||||
'12:30:00',
|
||||
'13:00:00',
|
||||
'13:30:00',
|
||||
'14:00:00',
|
||||
'14:30:00',
|
||||
'15:00:00',
|
||||
'15:30:00',
|
||||
'16:00:00',
|
||||
'16:30:00',
|
||||
'17:00:00',
|
||||
'17:30:00',
|
||||
'18:00:00',
|
||||
'18:30:00',
|
||||
];
|
||||
|
||||
PractitionerRole::chunk(100, function($chunkedPractitionerRoles) use ($times) {
|
||||
foreach ($chunkedPractitionerRoles as $practitionerRole) {
|
||||
$practitionerRole->practices()->insert([
|
||||
[
|
||||
'practitioner_role_id' => $practitionerRole->id,
|
||||
'service_code' => 'instant-chat',
|
||||
'active' => 1,
|
||||
],
|
||||
[
|
||||
'practitioner_role_id' => $practitionerRole->id,
|
||||
'service_code' => 'chat',
|
||||
'active' => 1,
|
||||
],
|
||||
[
|
||||
'practitioner_role_id' => $practitionerRole->id,
|
||||
'service_code' => 'video',
|
||||
'active' => 1,
|
||||
],
|
||||
[
|
||||
'practitioner_role_id' => $practitionerRole->id,
|
||||
'service_code' => 'walkin',
|
||||
'active' => 1,
|
||||
],
|
||||
]);
|
||||
|
||||
$availabilities_data = [];
|
||||
foreach($times as $time) {
|
||||
$availabilities_data[] = [
|
||||
'practitioner_role_id' => $practitionerRole->id,
|
||||
'all_day' => 0,
|
||||
'start_time' => $time
|
||||
];
|
||||
}
|
||||
|
||||
$practitionerRole->availabilities()->insert($availabilities_data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
58
database/seeders/ProvinceSeeder.php
Normal file
58
database/seeders/ProvinceSeeder.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Province;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProvinceSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Province::truncate();
|
||||
|
||||
$chunks = [];
|
||||
$time = now();
|
||||
if (($handle = fopen(resource_path('files/province.csv'), "r")) !== FALSE) {
|
||||
$firstline = true;
|
||||
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
|
||||
if (!$firstline) {
|
||||
$d = explode(';', $data[0]);
|
||||
|
||||
$row = [
|
||||
"id" => $d[0],
|
||||
"name" => ucwords(strtolower($d[1])),
|
||||
"created_at" => $time,
|
||||
"updated_at" => $time
|
||||
];
|
||||
|
||||
if ($row['name'] == 'Dki Jakarta') {
|
||||
$row['name'] = 'DKI Jakarta';
|
||||
}
|
||||
|
||||
$chunks[] = $row;
|
||||
}
|
||||
$firstline = false;
|
||||
|
||||
if ($chunks && count($chunks) == 100) {
|
||||
Province::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
}
|
||||
|
||||
if ($chunks && count($chunks) > 0) {
|
||||
Province::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
50
database/seeders/UpdateOrganizationCities.php
Normal file
50
database/seeders/UpdateOrganizationCities.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\District;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UpdateOrganizationCities extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$organizations = Organization::with('currentAddress')->get();
|
||||
|
||||
$districtsMap = [
|
||||
'ORG000C' => "367111",
|
||||
'ORG000D' => "327504",
|
||||
'ORG000E' => "317105",
|
||||
'ORG000F' => "737109",
|
||||
'ORG000M' => "327501",
|
||||
'ORG000O' => "732402",
|
||||
'ORG000P' => "327503",
|
||||
'ORG000Q' => "321503",
|
||||
'ORG000N' => "627103",
|
||||
'ORG000SG' => "337410",
|
||||
'ORG000BW' => "197104",
|
||||
'ORG000SK' => "320233",
|
||||
'ORG000PK' => "360312",
|
||||
'ORG000CK' => "317106",
|
||||
];
|
||||
|
||||
foreach ($organizations as $organization) {
|
||||
$district = District::with([
|
||||
'city',
|
||||
'city.province'
|
||||
])->find($districtsMap[$organization->code]);
|
||||
|
||||
$organization->currentAddress->district_id = $district->id ?? null;
|
||||
$organization->currentAddress->city_id = $district->city->id ?? null;
|
||||
$organization->currentAddress->province_id = $district->city->province->id ?? null;
|
||||
$organization->currentAddress->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
54
database/seeders/VillageSeeder.php
Normal file
54
database/seeders/VillageSeeder.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Village;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class VillageSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Village::truncate();
|
||||
|
||||
$chunks = [];
|
||||
$time = now();
|
||||
if (($handle = fopen(resource_path('files/village.csv'), "r")) !== FALSE) {
|
||||
$firstline = true;
|
||||
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
|
||||
if (!$firstline) {
|
||||
$d = explode(';', $data[0]);
|
||||
|
||||
$row = [
|
||||
"id" => $d[0],
|
||||
"district_id" => $d[1],
|
||||
"name" => ucwords(strtolower($d[2])),
|
||||
"created_at" => $time,
|
||||
"updated_at" => $time
|
||||
];
|
||||
|
||||
$chunks[] = $row;
|
||||
}
|
||||
$firstline = false;
|
||||
|
||||
if ($chunks && count($chunks) == 100) {
|
||||
Village::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
}
|
||||
|
||||
if ($chunks && count($chunks) > 0) {
|
||||
Village::insert($chunks);
|
||||
$chunks = [];
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user