Files
services_core/database/seeders/MenuListSeeder.php
T
2026-08-01 11:42:42 +07:00

436 lines
18 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\MenuGroup;
use App\Models\MenuList;
use Illuminate\Database\Seeder;
class MenuListSeeder extends Seeder
{
/**
* Seed default menu list for CoreUI navigation.
*/
public function run(): void
{
$users = MenuList::updateOrCreate(
['slug' => 'users'],
[
'parent_id' => null,
'name' => 'Pengguna',
'url' => null,
'icon' => 'cil-user',
'component' => null,
'sort_order' => 1,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'users-user'],
[
'parent_id' => $users->id,
'name' => 'Data Pengguna',
'url' => '/users',
'icon' => 'cil-people',
'component' => null,
'sort_order' => 1,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'users-group-menus'],
[
'parent_id' => $users->id,
'name' => 'Grup Menu',
'url' => '/group-menus',
'icon' => 'cil-list-rich',
'component' => null,
'sort_order' => 2,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'tenants'],
[
'parent_id' => null,
'name' => 'Tenant',
'url' => '/tenants',
'icon' => 'cil-layers',
'component' => null,
'sort_order' => 2,
'is_active' => true,
]
);
$ticketing = MenuList::updateOrCreate(
['slug' => 'ticketing'],
[
'parent_id' => null,
'name' => 'Ticketing',
'url' => null,
'icon' => 'cil-description',
'component' => null,
'sort_order' => 3,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'ticketing-material'],
[
'parent_id' => $ticketing->id,
'name' => 'Material',
'url' => '/materials',
'icon' => 'cil-layers',
'component' => null,
'sort_order' => 1,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'ticketing-ticket'],
[
'parent_id' => $ticketing->id,
'name' => 'Tiket',
'url' => '/tickets',
'icon' => 'cil-ticket',
'component' => null,
'sort_order' => 2,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'ticketing-approval'],
[
'parent_id' => $ticketing->id,
'name' => 'Persetujuan',
'url' => '/tickets/approval',
'icon' => 'cil-check-circle',
'component' => null,
'sort_order' => 3,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'ticketing-rejected'],
[
'parent_id' => $ticketing->id,
'name' => 'Ditolak',
'url' => '/tickets/rejected',
'icon' => 'cil-x-circle',
'component' => null,
'sort_order' => 4,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'ticketing-ticket-types'],
[
'parent_id' => $ticketing->id,
'name' => 'Jenis Tiket',
'url' => '/ticket-types',
'icon' => 'cil-tags',
'component' => null,
'sort_order' => 5,
'is_active' => true,
]
);
MenuList::updateOrCreate(
['slug' => 'ticketing-ticket-incidents'],
[
'parent_id' => $ticketing->id,
'name' => 'Insiden Tiket',
'url' => '/ticket-incident-types',
'icon' => 'cil-warning',
'component' => null,
'sort_order' => 6,
'is_active' => true,
]
);
$wilayah = MenuList::updateOrCreate(
['slug' => 'wilayah'],
[
'parent_id' => null,
'name' => 'Wilayah',
'url' => null,
'icon' => 'cil-location-pin',
'component' => null,
'sort_order' => 4,
'is_active' => true,
]
);
foreach ([
['slug' => 'wilayah-desa', 'name' => 'Desa', 'url' => '/wilayah/desa', 'sort_order' => 1],
['slug' => 'wilayah-kecamatan', 'name' => 'Kecamatan', 'url' => '/wilayah/kecamatan', 'sort_order' => 2],
['slug' => 'wilayah-kabupaten', 'name' => 'Kabupaten', 'url' => '/wilayah/kabupaten', 'sort_order' => 3],
['slug' => 'wilayah-provinsi', 'name' => 'Provinsi', 'url' => '/wilayah/provinsi', 'sort_order' => 4],
] as $item) {
MenuList::updateOrCreate(
['slug' => $item['slug']],
[
'parent_id' => $wilayah->id,
'name' => $item['name'],
'url' => $item['url'],
'icon' => 'cil-location-pin',
'component' => null,
'sort_order' => $item['sort_order'],
'is_active' => true,
]
);
}
$accessApplications = MenuList::updateOrCreate(['slug' => 'role-applications'], [
'parent_id' => null, 'name' => 'Permintaan Akses', 'url' => null,
'icon' => 'cil-user-follow', 'component' => null, 'sort_order' => 83,
]);
foreach ([
['slug' => 'role-applications-tenants', 'name' => 'Pengajuan Tenant', 'url' => '/access-applications/tenants', 'sort_order' => 1],
['slug' => 'role-applications-agents', 'name' => 'Pengajuan Agen', 'url' => '/access-applications/agents', 'sort_order' => 2],
['slug' => 'role-applications-staff', 'name' => 'Pengajuan Staff', 'url' => '/access-applications/staff', 'sort_order' => 3],
] as $item) {
MenuList::updateOrCreate(['slug' => $item['slug']], [
'parent_id' => $accessApplications->id, 'name' => $item['name'], 'url' => $item['url'],
'icon' => 'cil-user-follow', 'component' => null, 'sort_order' => $item['sort_order'],
]);
}
$staffApplicationMenu = MenuList::where('slug', 'role-applications-staff')->firstOrFail();
$groupManagementMenu = MenuList::where('slug', 'users-group-menus')->first();
if ($groupManagementMenu) {
MenuGroup::query()
->whereNull('tenant_id')
->where('is_system', true)
->whereHas('menus', fn ($query) => $query->whereKey($groupManagementMenu->id))
->each(function ($group) use ($accessApplications, $staffApplicationMenu) {
$permissions = [
'can_view' => true, 'can_create' => false, 'can_update' => false,
'can_delete' => false, 'can_approve' => true, 'can_export' => false,
];
$group->menus()->syncWithoutDetaching([
$accessApplications->id => $permissions,
$staffApplicationMenu->id => $permissions,
]);
});
}
$paymentGateway = MenuList::updateOrCreate(
['slug' => 'payment-gateway'],
[
'parent_id' => null, 'name' => 'Payment Gateway', 'url' => null,
'icon' => 'cil-credit-card', 'component' => null, 'sort_order' => 80,
]
);
foreach ([
['slug' => 'payment-gateway-settings', 'name' => 'Setting', 'url' => '/payment-gateway/settings', 'sort_order' => 1],
['slug' => 'payment-gateway-logs', 'name' => 'Log Pembayaran', 'url' => '/payment-gateway/logs', 'sort_order' => 2],
] as $item) {
MenuList::updateOrCreate(['slug' => $item['slug']], [
'parent_id' => $paymentGateway->id, 'name' => $item['name'], 'url' => $item['url'],
'icon' => 'cil-credit-card', 'component' => null, 'sort_order' => $item['sort_order'],
]);
}
MenuList::updateOrCreate(['slug' => 'wallet'], [
'parent_id' => null, 'name' => 'Saldo Deposit', 'url' => '/deposit-balance',
'icon' => 'cil-wallet', 'component' => null, 'sort_order' => 81,
]);
$voucherHotspot = MenuList::updateOrCreate(
['slug' => 'voucher-hotspot'],
[
'parent_id' => null, 'name' => 'Voucher Hotspot', 'url' => null,
'icon' => 'cil-barcode', 'component' => null, 'sort_order' => 82,
]
);
foreach ([
['slug' => 'voucher-hotspot-sales', 'name' => 'Jual Voucher', 'url' => '/voucher-hotspot/sales', 'sort_order' => 1],
['slug' => 'voucher-hotspot-agents', 'name' => 'Agen Voucher', 'url' => '/voucher-hotspot/agents', 'sort_order' => 2],
['slug' => 'voucher-hotspot-login-page', 'name' => 'Voucher LoginPage', 'url' => '/voucher-hotspot/login-page', 'sort_order' => 3],
] as $item) {
MenuList::updateOrCreate(['slug' => $item['slug']], [
'parent_id' => $voucherHotspot->id, 'name' => $item['name'], 'url' => $item['url'],
'icon' => 'cil-barcode', 'component' => null, 'sort_order' => $item['sort_order'],
]);
}
$nas = MenuList::updateOrCreate(
['slug' => 'nas'],
[
'parent_id' => null,
'name' => 'NAS',
'url' => null,
'icon' => 'cil-settings',
'component' => null,
'sort_order' => 5,
'is_active' => true,
]
);
foreach ([
['slug' => 'nas-mikrotik', 'name' => 'Mikrotik', 'url' => '/nas/mikrotik', 'icon' => 'cil-settings', 'sort_order' => 1],
['slug' => 'nas-package-profiles', 'name' => 'Profile Paket', 'url' => '/nas/package-profiles', 'icon' => 'cil-speedometer', 'sort_order' => 2],
['slug' => 'nas-olt', 'name' => 'OLT', 'url' => '/nas/olt', 'icon' => 'cil-layers', 'sort_order' => 3],
['slug' => 'nas-webfig', 'name' => 'Webfig', 'url' => '/nas/webfig', 'icon' => 'cil-laptop', 'sort_order' => 4],
] as $item) {
MenuList::updateOrCreate(
['slug' => $item['slug']],
[
'parent_id' => $nas->id,
'name' => $item['name'],
'url' => $item['url'],
'icon' => $item['icon'],
'component' => null,
'sort_order' => $item['sort_order'],
'is_active' => true,
]
);
}
$customers = MenuList::updateOrCreate(
['slug' => 'customers'],
[
'parent_id' => null,
'name' => 'Customer',
'url' => null,
'icon' => 'cil-people',
'component' => null,
'sort_order' => 6,
'is_active' => true,
]
);
foreach ([
['slug' => 'customers-orders', 'name' => 'List Order', 'url' => '/customers/orders', 'sort_order' => 1],
['slug' => 'customers-active', 'name' => 'Aktif', 'url' => '/customers/active', 'sort_order' => 2],
['slug' => 'customers-inactive', 'name' => 'Tidak Aktif', 'url' => '/customers/inactive', 'sort_order' => 3],
['slug' => 'customers-unmanaged', 'name' => 'Unmanage', 'url' => '/customers/unmanaged', 'sort_order' => 4],
['slug' => 'customers-trash', 'name' => 'Sampah', 'url' => '/customers/trash', 'sort_order' => 5],
] as $item) {
MenuList::updateOrCreate(
['slug' => $item['slug']],
[
'parent_id' => $customers->id,
'name' => $item['name'],
'url' => $item['url'],
'icon' => 'cil-user',
'component' => null,
'sort_order' => $item['sort_order'],
'is_active' => true,
]
);
}
$billing = MenuList::updateOrCreate(
['slug' => 'billing'],
[
'parent_id' => null,
'name' => 'Tagihan',
'url' => null,
'icon' => 'cil-description',
'component' => null,
'sort_order' => 7,
'is_active' => true,
]
);
foreach ([
['slug' => 'billing-profiles', 'name' => 'Profile Tagihan', 'url' => '/billing/profiles', 'sort_order' => 1],
['slug' => 'billing-running', 'name' => 'Tagihan Berjalan', 'url' => '/billing/running', 'sort_order' => 2],
['slug' => 'billing-overdue', 'name' => 'Tunggakan', 'url' => '/billing/overdue', 'sort_order' => 3],
['slug' => 'billing-paid', 'name' => 'Lunas', 'url' => '/billing/paid', 'sort_order' => 4],
] as $item) {
MenuList::updateOrCreate(
['slug' => $item['slug']],
[
'parent_id' => $billing->id,
'name' => $item['name'],
'url' => $item['url'],
'icon' => 'cil-dollar',
'component' => null,
'sort_order' => $item['sort_order'],
'is_active' => true,
]
);
}
$topology = MenuList::updateOrCreate(
['slug' => 'topology'],
[
'parent_id' => null,
'name' => 'Topologi',
'url' => null,
'icon' => 'cil-layers',
'component' => null,
'sort_order' => 8,
'is_active' => true,
]
);
foreach ([
['slug' => 'topology-map', 'name' => 'Peta Jaringan', 'url' => '/topology/map', 'icon' => 'cil-location-pin', 'sort_order' => 1],
['slug' => 'topology-devices', 'name' => 'Perangkat', 'url' => '/topology/devices', 'icon' => 'cil-settings', 'sort_order' => 2],
['slug' => 'topology-links', 'name' => 'Jalur Kabel', 'url' => '/topology/links', 'icon' => 'cil-layers', 'sort_order' => 3],
['slug' => 'topology-network', 'name' => 'Topologi Jaringan', 'url' => '/topology/network', 'icon' => 'cil-grid', 'sort_order' => 4],
['slug' => 'topology-device-types', 'name' => 'Kategori Perangkat', 'url' => '/topology/device-types', 'icon' => 'cil-list', 'sort_order' => 5],
] as $item) {
MenuList::updateOrCreate(
['slug' => $item['slug']],
[
'parent_id' => $topology->id,
'name' => $item['name'],
'url' => $item['url'],
'icon' => $item['icon'],
'component' => null,
'sort_order' => $item['sort_order'],
'is_active' => true,
]
);
}
$notifications = MenuList::updateOrCreate(
['slug' => 'notifications-service'],
[
'parent_id' => null,
'name' => 'Notifikasi',
'url' => null,
'icon' => 'cil-bell',
'component' => null,
'sort_order' => 9,
'is_active' => true,
]
);
foreach ([
['slug' => 'notifications-broadcasts', 'name' => 'Pesan Siaran', 'url' => '/notifications-service/broadcasts', 'icon' => 'cil-speech', 'sort_order' => 1],
['slug' => 'notifications-system', 'name' => 'Notifikasi Aplikasi', 'url' => '/notifications-service/system', 'icon' => 'cil-bell', 'sort_order' => 2],
['slug' => 'notifications-wa-official', 'name' => 'WhatsApp Official', 'url' => '/notifications-service/whatsapp-official', 'icon' => 'cil-comment-square', 'sort_order' => 3],
['slug' => 'notifications-wa-unofficial', 'name' => 'WhatsApp Unofficial', 'url' => '/notifications-service/whatsapp-unofficial', 'icon' => 'cil-comment-square', 'sort_order' => 4],
['slug' => 'notifications-email', 'name' => 'Email', 'url' => '/notifications-service/email', 'icon' => 'cil-envelope-open', 'sort_order' => 5],
['slug' => 'notifications-telegram', 'name' => 'Telegram', 'url' => '/notifications-service/telegram', 'icon' => 'cil-arrow-right', 'sort_order' => 6],
] as $item) {
MenuList::updateOrCreate(
['slug' => $item['slug']],
[
'parent_id' => $notifications->id,
'name' => $item['name'],
'url' => $item['url'],
'icon' => $item['icon'],
'component' => null,
'sort_order' => $item['sort_order'],
'is_active' => true,
]
);
}
}
}