feat:complete admin permissions for admin side

This commit is contained in:
2026-08-19 19:20:32 +03:30
parent 29ddbe2e0f
commit 894ae6794d
3 changed files with 15 additions and 18 deletions
@@ -8,24 +8,15 @@ use Symfony\Component\HttpFoundation\Response;
class AdminPermissionMiddleware
{
/**
* Handle an incoming request.
*
* @param Closure(Request): (Response) $next
*/
public function handle(Request $request, Closure $next, string $permission): Response
{
public function handle(
Request $request,
Closure $next,
string $permission
): Response {
$admin = auth('admin')->user();
if (!$admin) {
abort(403);
}
$hasPermission = $admin->permissions()
->where('name', $permission)
->exists();
if (!$hasPermission) {
if (!$admin->permission?->{$permission}) {
abort(403, 'شما اجازه دسترسی به این بخش را ندارید.');
}