Created
December 27, 2023 05:11
-
-
Save rwaddin/e43ff9826617a84c66450d89232c4e8c to your computer and use it in GitHub Desktop.
sample limitasi menu permission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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