Files
ilycats/app/Traits/HasPermissions.php
T

15 lines
397 B
PHP
Raw Normal View History

2026-02-08 15:16:35 +07:00
<?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()
->where('module_slug', $moduleSlug)
->where($action, 1)
->exists();
}
}