update
This commit is contained in:
36
database/migrations/2024_07_08_085748_add_column_to_corporates.php
Executable file
36
database/migrations/2024_07_08_085748_add_column_to_corporates.php
Executable file
@@ -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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('corporates', function (Blueprint $table) {
|
||||
$table->string('phone')->nullable();
|
||||
$table->string('phone_alarm_canter')->nullable();
|
||||
$table->text('description_information')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('corporates', function (Blueprint $table) {
|
||||
$table->dropColumn('phone');
|
||||
$table->dropColumn('phone_alarm_canter');
|
||||
$table->dropColumn('description_information');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('drugs', function (Blueprint $table) {
|
||||
$table->string('unit')->nullable()->after('generic_name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('drugs', function (Blueprint $table) {
|
||||
$table->dropColumn('unit');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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::table('organizations', function (Blueprint $table) {
|
||||
$table->string('phone')->nullable()->after('main_address_id');
|
||||
$table->string('email')->nullable()->after('phone');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('organizations', function (Blueprint $table) {
|
||||
$table->dropColumn('phone');
|
||||
$table->dropColumn('email');
|
||||
});
|
||||
}
|
||||
};
|
||||
173
database/seeders/ApotekMandiriInhealtSeeder.php
Normal file
173
database/seeders/ApotekMandiriInhealtSeeder.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Organization;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
|
||||
class ApotekMandiriInhealtSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$file_path = resource_path('files/data-apotik-layanan-pharmacy-delivery.xlsx');
|
||||
$reader = ReaderEntityFactory::createReaderFromFile($file_path);
|
||||
$reader->open($file_path);
|
||||
|
||||
$cell_map = [ // Urutan kolom di excel
|
||||
'No',
|
||||
'Nama KOP',
|
||||
'Nama KLY',
|
||||
'Kode Provider',
|
||||
'Nama Provider',
|
||||
'Jalan',
|
||||
'KODEPOS',
|
||||
'OPERASIONAL DAY',
|
||||
'OPERASIONAL HOUR',
|
||||
'AVAILABLE Brozo',
|
||||
'Geo Tag'
|
||||
];
|
||||
|
||||
foreach ($reader->getSheetIterator() as $sheet) {
|
||||
$previousCells = null;
|
||||
foreach ($sheet->getRowIterator() as $index => $row) {
|
||||
if ($index >= 4) {
|
||||
$cells = $row->getCells();
|
||||
$data = [];
|
||||
|
||||
// Check Merging
|
||||
if ($cells[0]->getValue() == '' && $cells[1]->getValue() == '' && $cells[2]->getValue() == '' && $cells[3]->getValue() == '' && $cells[4]->getValue() == '' && $cells[5]->getValue() == '' && $cells[6]->getValue() == '' && $cells[9]->getValue() == '' && $cells[10]->getValue() == '' && $cells[11]->getValue() == '' && $cells[12]->getValue() == '') {
|
||||
$data = [
|
||||
'code' => $previousCells[3]->getValue(),
|
||||
'name' => $previousCells[4]->getValue(),
|
||||
'type' => 'hospital',
|
||||
'corporate_id_partner' => 8, // Mandiri Inhealth
|
||||
'phone' => $previousCells[11]->getValue(),
|
||||
'email' => isset($previousCells[12]) ? $previousCells[12]->getValue() : null,
|
||||
'operational_day' => $this->expandDaysRange($previousCells[7]->getValue(), [$cells[7]->getValue()]),
|
||||
'operational_hour' => $previousCells[8]->getValue() == "24 jam" ? "00:00-24:00" : $previousCells[8]->getValue(),
|
||||
'operational_day_other' => $cells[7]->getValue(),
|
||||
'operational_hour_other' => $cells[8]->getValue()
|
||||
];
|
||||
|
||||
// Update or create organization
|
||||
$organization = Organization::updateOrCreate(
|
||||
['code' => $previousCells[3]->getValue()],
|
||||
$data
|
||||
);
|
||||
|
||||
|
||||
// Update or create address
|
||||
$geo = str_replace("'", "", $previousCells[9]->getValue()); // Hilangkan tanda petik tunggal
|
||||
$datageo = explode(",", $geo);
|
||||
|
||||
// Pastikan $datageo memiliki dua elemen sebelum mencoba mengaksesnya
|
||||
$lat = isset($datageo[0]) ? $datageo[0] : null;
|
||||
$lng = isset($datageo[1]) ? $datageo[1] : null;
|
||||
|
||||
$address = $organization->addresses()->updateOrCreate(
|
||||
['addressable_id' => $organization->id],
|
||||
[
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $previousCells[5]->getValue(),
|
||||
'postal_code' => $previousCells[6]->getValue(),
|
||||
'lat' => $lat,
|
||||
'lng' => $lng,
|
||||
]
|
||||
);
|
||||
|
||||
// Set main address id
|
||||
$organization->main_address_id = $address->id;
|
||||
$organization->save();
|
||||
} else {
|
||||
$data = [
|
||||
'code' => $cells[3]->getValue(),
|
||||
'name' => $cells[4]->getValue(),
|
||||
'type' => 'hospital',
|
||||
'corporate_id_partner' => 8, // Mandiri Inhealth
|
||||
'phone' => $cells[11]->getValue(),
|
||||
'email' => isset($cells[12]) ? $cells[12]->getValue() : null,
|
||||
'operational_day' => $this->expandDaysRange($cells[7]->getValue()),
|
||||
'operational_hour' => $cells[8]->getValue() == "24 jam" ? "00:00-24:00" : $cells[8]->getValue(),
|
||||
];
|
||||
|
||||
// Update or create organization
|
||||
$organization = Organization::updateOrCreate(
|
||||
['code' => $cells[3]->getValue()],
|
||||
$data
|
||||
);
|
||||
|
||||
|
||||
// Update or create address
|
||||
$geo = str_replace("'", "", $cells[9]->getValue()); // Hilangkan tanda petik tunggal
|
||||
$datageo = explode(",", $geo);
|
||||
|
||||
// Pastikan $datageo memiliki dua elemen sebelum mencoba mengaksesnya
|
||||
$lat = isset($datageo[0]) ? $datageo[0] : null;
|
||||
$lng = isset($datageo[1]) ? $datageo[1] : null;
|
||||
|
||||
$address = $organization->addresses()->updateOrCreate(
|
||||
['addressable_id' => $organization->id],
|
||||
[
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $cells[5]->getValue(),
|
||||
'postal_code' => $cells[6]->getValue(),
|
||||
'lat' => $lat,
|
||||
'lng' => $lng,
|
||||
]
|
||||
);
|
||||
|
||||
// Set main address id
|
||||
$organization->main_address_id = $address->id;
|
||||
$organization->save();
|
||||
}
|
||||
|
||||
$previousCells = $cells;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reader->close();
|
||||
|
||||
}
|
||||
|
||||
private function expandDaysRange($input, $excludedDays = []) {
|
||||
// Daftar hari dalam seminggu
|
||||
$daysOfWeek = ["Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu"];
|
||||
|
||||
// Pisahkan input berdasarkan tanda "-"
|
||||
$range = array_map('trim', explode('-', $input));
|
||||
|
||||
if (count($range) == 2) {
|
||||
// Cari posisi hari pertama dan hari terakhir di dalam array $daysOfWeek
|
||||
$startIndex = array_search($range[0], $daysOfWeek);
|
||||
$endIndex = array_search($range[1], $daysOfWeek);
|
||||
|
||||
// Jika ditemukan, ambil rentang hari
|
||||
if ($startIndex !== false && $endIndex !== false && $startIndex <= $endIndex) {
|
||||
// Ambil hari-hari dalam rentang tersebut
|
||||
$daysRange = array_slice($daysOfWeek, $startIndex, ($endIndex - $startIndex + 1));
|
||||
|
||||
// Jika ada hari yang ingin di-exclude, hapus dari $daysRange
|
||||
if (!empty($excludedDays)) {
|
||||
$daysRange = array_diff($daysRange, $excludedDays);
|
||||
}
|
||||
|
||||
// Gabungkan menjadi string dengan koma
|
||||
return implode(',', $daysRange);
|
||||
} else {
|
||||
return "Hari tidak valid atau rentang tidak benar.";
|
||||
}
|
||||
} else {
|
||||
return "Format input tidak sesuai.";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,9 +170,14 @@ class NavigationSeeder extends Seeder
|
||||
// ['title' => 'Prescription', 'path' => '/report/prescription'],
|
||||
[
|
||||
'title' => 'Doctor Rating',
|
||||
'path' => '/report/doctorrating',
|
||||
'path' => '/report/doctor-rating',
|
||||
'permission' => 'report-doctor-rating'
|
||||
],
|
||||
[
|
||||
'title' => 'Katalog Dokter',
|
||||
'path' => '/report/katalog-dokter',
|
||||
'permission' => 'report-katalog-dokter'
|
||||
]
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
@@ -261,30 +266,46 @@ class NavigationSeeder extends Seeder
|
||||
],
|
||||
'permission' => 'case-management-client-portal'
|
||||
],
|
||||
[
|
||||
'title' => 'User Management',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'User Role',
|
||||
'path' => '/user-role',
|
||||
'permission' => 'user-role-list-client-portal'
|
||||
],
|
||||
[
|
||||
'title' => 'User Access',
|
||||
'path' => '/user-access',
|
||||
'permission' => 'user-access-list-client-portal'
|
||||
]
|
||||
],
|
||||
'permission' => 'user-management-client-portal'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($menuItems as $menuItemData) {
|
||||
$menuItem = Navigations::updateOrCreate([
|
||||
'title' => $menuItemData['title'],
|
||||
'permission' => $menuItemData['permission']
|
||||
'permission' => $menuItemData['permission'] ?? null
|
||||
],
|
||||
[
|
||||
'title' => $menuItemData['title'],
|
||||
'path' => $menuItemData['path'] ?? null,
|
||||
'permission' => $menuItemData['permission']
|
||||
'permission' => $menuItemData['permission'] ?? null
|
||||
]);
|
||||
|
||||
if (isset($menuItemData['children'])) {
|
||||
foreach ($menuItemData['children'] as $childData) {
|
||||
$menuItemChildren = Navigations::updateOrCreate([
|
||||
'title' => $childData['title'],
|
||||
'permission' => $childData['permission']
|
||||
'permission' => $childData['permission'] ?? null
|
||||
],
|
||||
[
|
||||
'title' => $childData['title'],
|
||||
'path' => $childData['path'] ?? null,
|
||||
'parent_id' => $menuItem->id,
|
||||
'permission' => $childData['permission']
|
||||
'permission' => $childData['permission'] ?? null
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,8 @@ class PermissionTableSeeder extends Seeder
|
||||
'report-livechat-payment',
|
||||
'report-doctor-rating',
|
||||
'user-role-list',
|
||||
'user-access-list'
|
||||
'user-access-list',
|
||||
'report-katalog-dokter'
|
||||
]
|
||||
],
|
||||
####################### CLIENT PORTAL #########################
|
||||
@@ -86,6 +87,9 @@ class PermissionTableSeeder extends Seeder
|
||||
'formularium-list-client-portal',
|
||||
'case-management-client-portal',
|
||||
'service-monitoring-limit-client-portal',
|
||||
'user-management-client-portal',
|
||||
'user-role-list-client-portal',
|
||||
'user-access-list-client-portal'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user