User access dan user role dinamis
This commit is contained in:
@@ -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::create('navigations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('path');
|
||||
$table->string('icon');
|
||||
$table->string('permission');
|
||||
$table->foreignId('parent_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('navigations');
|
||||
}
|
||||
};
|
||||
247
database/seeders/NavigationSeeder.php
Normal file
247
database/seeders/NavigationSeeder.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Navigations;
|
||||
|
||||
class NavigationSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$menuItems = [
|
||||
// DOCTORS & HOSPITALS
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'path' => '/dashboard',
|
||||
'permission' => 'dashboard'
|
||||
],
|
||||
// DOCTORS & HOSPITALS
|
||||
[
|
||||
'title' => 'DOCTORS & HOSPITALS',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Doctors',
|
||||
'path' => '/master/doctors',
|
||||
'permission' => 'doctor-list'
|
||||
],
|
||||
[
|
||||
'title' => 'Hospitals',
|
||||
'path' => '/master/hospitals',
|
||||
'permission' => 'hospital-list'
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// PHARMACY & DELIVERY MANAGEMENT
|
||||
[
|
||||
'title' => 'PHARMACY & DELIVERY MANAGEMENT',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Drug',
|
||||
'path' => '/master/drugs',
|
||||
'permission' => 'drug-list'
|
||||
],
|
||||
[
|
||||
'title' => 'Inventory',
|
||||
'path' => '/inventory',
|
||||
'permission' => null
|
||||
],
|
||||
[
|
||||
'title' => 'Delivery Services',
|
||||
'path' => '/delivery',
|
||||
'permission' => null
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// STATION BENEFIT & MEMBERSHIP
|
||||
[
|
||||
'title' => 'STATION BENEFIT & MEMBERSHIP',
|
||||
'openWhen' => ['/corporates', '/formularium', '/diagnosis', '/hospitals'],
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Corporate',
|
||||
'path' => '/corporates',
|
||||
'permission' => 'corporate-list',
|
||||
],
|
||||
// ['title' => 'Corporate Create', 'path' => '/corporates/create'],
|
||||
[
|
||||
'title' => 'Formularium',
|
||||
'path' => '/master/formularium-template-v2',
|
||||
'permission' => 'formularium-list',
|
||||
],
|
||||
[
|
||||
'title' => 'Master ICD-10 Diagnosis',
|
||||
'path' => '/master/diagnosis',
|
||||
'permission' => 'diagnosis-list',
|
||||
],
|
||||
[
|
||||
'title' => 'Hospitals',
|
||||
'path' => '/hospitals',
|
||||
'permission' => null,
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// CLAIM REQUEST
|
||||
[
|
||||
'title' => 'CLAIM REQUEST',
|
||||
'path' => '/claim-requests',
|
||||
'permission' => 'claim-request-list'
|
||||
],
|
||||
// CLAIM MANAGEMENT
|
||||
[
|
||||
'title' => 'CLAIM MANAGEMENT',
|
||||
'path' => '/claims',
|
||||
'permission' => 'claim-management-list'
|
||||
],
|
||||
// CASE MANAGEMENT
|
||||
[
|
||||
'title' => 'CASE MANAGEMENT',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Daily Monitoring',
|
||||
'path' => '/case_management/daily_monitoring',
|
||||
'permission' => 'daily-monitoring-list'
|
||||
],
|
||||
// ['title' => 'Laboratorium Result', 'path' => '/case_management/laboratorium_result'],
|
||||
[
|
||||
'title' => 'Inpatient Monitoring',
|
||||
'path' => '/case_management/inpatient_monitoring',
|
||||
'permission' => 'final-log-list'
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// CUSTOMER SERVICES
|
||||
[
|
||||
'title' => 'CUSTOMER SERVICES',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Request',
|
||||
'path' => '/custormer-service/request',
|
||||
'permission' => 'request-log-list'
|
||||
],
|
||||
// ['title' => 'Membership', 'path' => '/cs-membership'],
|
||||
[
|
||||
'title' => 'Final LOG',
|
||||
'path' => '/custormer-service/final-log',
|
||||
'permission' => 'final-log-list'
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// REPORT
|
||||
[
|
||||
'title' => 'REPORT',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Files Provider',
|
||||
'path' => 'report/files-provider',
|
||||
'permission' => 'report-files-provider-list'
|
||||
],
|
||||
[
|
||||
'title' => 'Letter of Guarantee',
|
||||
'path' => '/report/logs',
|
||||
'permission' => 'report-log-list'
|
||||
],
|
||||
[
|
||||
'title' => 'Appointment',
|
||||
'path' => '/report/appointments',
|
||||
'permission' => 'report-appointment-list'
|
||||
],
|
||||
[
|
||||
'title' => 'Live Chat',
|
||||
'path' => '/report/live-chat',
|
||||
'permission' => 'report-livechat-list'
|
||||
],
|
||||
[
|
||||
'title' => 'Linksehat Payment',
|
||||
'path' => '/report/linksehat-payments',
|
||||
'permission' => 'report-livechat-payment'
|
||||
],
|
||||
// ['title' => 'Prescription', 'path' => '/report/prescription'],
|
||||
[
|
||||
'title' => 'Doctor Rating',
|
||||
'path' => '/report/doctorrating',
|
||||
'permission' => 'report-doctor-rating'
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// MASTER
|
||||
[
|
||||
'title' => 'MASTER',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Diagnosis',
|
||||
'path' => '/master/diagnosis',
|
||||
'permission' => 'diagnosis-list'
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// USER MANAGEMENT
|
||||
[
|
||||
'title' => 'USER MANAGEMENT',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'User Role',
|
||||
'path' => '/user-role',
|
||||
'permission' => 'user-role-list'
|
||||
],
|
||||
[
|
||||
'title' => 'User Access',
|
||||
'path' => '/user-access',
|
||||
'permission' => 'user-role-access'
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// LINKING TOOLS
|
||||
[
|
||||
'title' => 'LINKING TOOLS',
|
||||
'path' => '/linking',
|
||||
'permission' => 'linkking-list'
|
||||
],
|
||||
// E-PRESCRIPTION
|
||||
[
|
||||
'title' => 'E-PRESCRIPTION',
|
||||
'path' => '/e-prescription/live-chat',
|
||||
'permission' => 'prescription-list'
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($menuItems as $menuItemData) {
|
||||
$menuItem = Navigations::updateOrCreate([
|
||||
'title' => $menuItemData['title']
|
||||
],
|
||||
[
|
||||
'title' => $menuItemData['title'],
|
||||
'path' => $menuItemData['path'] ?? null,
|
||||
'permission' => $menuItemData['permission']
|
||||
]);
|
||||
|
||||
if (isset($menuItemData['children'])) {
|
||||
foreach ($menuItemData['children'] as $childData) {
|
||||
$menuItemChildren = Navigations::updateOrCreate([
|
||||
'title' => $childData['title']
|
||||
],
|
||||
[
|
||||
'title' => $childData['title'],
|
||||
'path' => $childData['path'] ?? null,
|
||||
'parent_id' => $menuItem->id,
|
||||
'permission' => $childData['permission']
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
database/seeders/PermissionTableSeeder.php
Normal file
81
database/seeders/PermissionTableSeeder.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
|
||||
class PermissionTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$permissions = [
|
||||
'dashboard',
|
||||
'doctor-list',
|
||||
'doctor-create',
|
||||
'doctor-edit',
|
||||
'doctor-delete',
|
||||
'hospital-list',
|
||||
'hospital-create',
|
||||
'hospital-edit',
|
||||
'hospital-delete',
|
||||
'drug-list',
|
||||
'drug-create',
|
||||
'drug-edit',
|
||||
'drug-delete',
|
||||
'corporate-list',
|
||||
'corporate-create',
|
||||
'corporate-edit',
|
||||
'corporate-delete',
|
||||
'formularium-list',
|
||||
'formularium-create',
|
||||
'formularium-edit',
|
||||
'formularium-delete',
|
||||
'diagnosis-list',
|
||||
'diagnosis-create',
|
||||
'diagnosis-edit',
|
||||
'diagnosis-delete',
|
||||
'claim-request-list',
|
||||
'claim-request-create',
|
||||
'claim-request-edit',
|
||||
'claim-request-delete',
|
||||
'claim-management-list',
|
||||
'claim-management-create',
|
||||
'claim-management-edit',
|
||||
'claim-management-delete',
|
||||
'daily-monitoring-list',
|
||||
'request-log-list',
|
||||
'request-log-create',
|
||||
'request-log-edit',
|
||||
'request-log-delete',
|
||||
'final-log-list',
|
||||
'final-log-create',
|
||||
'final-log-edit',
|
||||
'final-log-delete',
|
||||
'report-files-provider-list',
|
||||
'report-letter-of-guarante-list',
|
||||
'report-log-list',
|
||||
'report-appointment-list',
|
||||
'report-livechat-list',
|
||||
'report-livechat-payment',
|
||||
'report-doctor-rating',
|
||||
'user-role-list',
|
||||
'user-access-list'
|
||||
];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
Permission::updateOrCreate(['name' => $permission],
|
||||
[
|
||||
'name' => $permission,
|
||||
'guard_name' => 'web'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user