@extends('layouts.app') @section('content')
| # | Name | Role | Branch | Actions | |
|---|---|---|---|---|---|
| {{ $user->id }} | {{ $user->name }} | {{ $user->email }} | {{ str_replace('_', ' ', $user->role) }} | @if(in_array($user->role, ['super_admin', 'co_admin'])) N/A @else {{ $user->branch?->name ?? 'N/A' }} @endif | {{-- Inline logic for Edit: Super admin always, co_admin if not super_admin, branch_admin if same branch and role branch_admin/staff --}} @if(auth()->user()->role === 'super_admin' || (auth()->user()->role === 'co_admin' && $user->role !== 'super_admin') || (auth()->user()->role === 'branch_admin' && in_array($user->role, ['branch_admin', 'staff']) && $user->branch_id === auth()->user()->branch_id)) Edit @else No edit @endif {{-- Inline logic for Delete: Super admin if not self, co_admin never, branch_admin if staff in same branch and not self --}} @if((auth()->user()->role === 'super_admin' && $user->id !== auth()->user()->id) || (auth()->user()->role === 'branch_admin' && $user->role === 'staff' && $user->branch_id === auth()->user()->branch_id && $user->id !== auth()->user()->id)) @else No delete @endif |
| No users found. | |||||