Skip to content

Instantly share code, notes, and snippets.

@rwaddin
Created December 27, 2023 05:11
Show Gist options
  • Save rwaddin/e43ff9826617a84c66450d89232c4e8c to your computer and use it in GitHub Desktop.
Save rwaddin/e43ff9826617a84c66450d89232c4e8c to your computer and use it in GitHub Desktop.
sample limitasi menu permission
<?php
function akses ($title, $menu=false){
$mainmenu= [
"dashboard" => [
"performa_usaha" => [
"performa_toko.lihat",
"biaya.lihat",
"omset.lihat",
"dll.lihat",
],
"transaksi" => [
"transaksi_hapus.lihat",
"dkk.lihat",
"dkk.lihat",
"dll.lihat",
],
"laporan" => [
"bukubesar.lihat",
"dkk.lihat",
"dll.lihat",
"dkk.lihat",
]
],
"master" => [
]
];
# untuk dropdown akses('dashboard','performa_usaha')
if($menu){
return isset($mainmenu[$title][$menu]) ? $mainmenu[$title][$menu] : [];
}
# untuk title akses('dashboard')
if(isset($mainmenu[$title])){
$permission = [];
foreach($mainmenu[$title] as $row){
$permission = array_merge($permission, $row);
}
return $permission;
}
return [];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment