@extends('layouts.app') @section('title', 'Branch Management') @section('content')

Branch Management

Manage branches and their locations
{{ $totalSubBranches }}
Total Branches
{{ $activeSubBranches }}
Active Branches
{{ $inactiveSubBranches }}
Inactive Branches
Branches List ({{ $subBranches->total() }} branches)
@forelse($subBranches as $index => $subBranch) @empty @endforelse
SL Name Admin User Parent Branch Parent User Assigned Router Total Clients Status Active Created Actions
{{ $subBranches->firstItem() + $index }}
{{ $subBranch->name }}
{{ $subBranch->code }}
@if($subBranch->users->isNotEmpty()) @php $user = $subBranch->users->first(); @endphp
{{ $user->name }}
{{ $user->email }}
{{ ucfirst($user->role) }}
@else No User @endif
@if($subBranch->parentBranch)
{{ $subBranch->parentBranch->name }}
{{ $subBranch->parentBranch->code }}
@else No Parent @endif
@if($subBranch->users->isNotEmpty()) @php $user = $subBranch->users->first(); @endphp @if($user->parentUser)
{{ $user->parentUser->name }}
{{ $user->parentUser->email }}
@else No Parent User @endif @else No User @endif
@if($subBranch->mikrotikServers->count() > 0) @foreach($subBranch->mikrotikServers as $server)
{{ $server->name }}
{{ $server->host }}:{{ $server->port }} @if($server->is_primary) Primary @endif
@endforeach @else No Router Assigned @endif
{{ $subBranch->clients_count }}
Clients
@if($subBranch->users->isNotEmpty()) @php $user = $subBranch->users->first(); @endphp @if($user->status === 'active') Active @elseif($user->status === 'inactive') Inactive @elseif($user->status === 'suspended') Suspended @else {{ ucfirst($user->status) }} @endif @else No User @endif @if($subBranch->is_active) Active @else Inactive @endif
{{ $subBranch->created_at->format('M d, Y') }}
{{ $subBranch->created_at->format('h:i A') }}
@php $currentUser = auth()->user(); $isSuperAdmin = false; // Check for super admin role (case insensitive) if (in_array(strtolower($currentUser->role), ['super_admin', 'super-admin', 'super admin'])) { $isSuperAdmin = true; } // Check for specific super admin emails if (in_array($currentUser->email, ['mkzwasim@gmail.com', 'sahrior@gmail.com', 'wasim@mkz.com.bd'])) { $isSuperAdmin = true; } // Debug information $debugInfo = [ 'current_user_role' => $currentUser->role, 'current_user_email' => $currentUser->email, 'is_super_admin' => $isSuperAdmin, 'sub_branch_users_count' => $subBranch->users->count(), 'sub_branch_id' => $subBranch->id ]; @endphp @if($subBranch->users->isNotEmpty()) @php $user = $subBranch->users->first(); @endphp @else Debug: {{ $debugInfo['current_user_role'] }} | {{ $debugInfo['is_super_admin'] ? 'SA' : 'Not SA' }} | Users: {{ $debugInfo['sub_branch_users_count'] }} @endif
No Branches Found

Start by creating your first branch.

Add Branch
@if($subBranches->hasPages())
Showing {{ $subBranches->firstItem() }} to {{ $subBranches->lastItem() }} of {{ $subBranches->total() }} results
{{ $subBranches->links() }}
@endif
@endsection @section('scripts') @endsection