initial commit

This commit is contained in:
2026-09-23 12:45:02 +07:00
parent d16f454083
commit 507fc6ccdf
235 changed files with 19587 additions and 2835 deletions
+13 -9
View File
@@ -1,15 +1,19 @@
<?php
namespace App\Traits;
trait HasPermissions {
public function hasPermission($moduleSlug, $action) {
// Jika user tidak punya role, akses ditolak
if (!$this->role) return false;
// Cek ke tabel permission_role
return $this->role->permissions()
trait HasPermissions
{
public function hasPermission($moduleSlug, $action): bool
{
if ($this->getRawOriginal('role') === 'admin') {
return true;
}
$role = $this->roleModel;
if (!$role) return false;
$column = str_starts_with($action, 'can_') ? $action : 'can_' . $action;
return $role->permissions()
->where('module_slug', $moduleSlug)
->where($action, 1)
->where($column, 1)
->exists();
}
}
}