@foreach ($users as $user) @php $userJob = $user->user_job(); $subtypeIds = $userJob ? json_decode($userJob->subtypes) : []; if (is_array($subtypeIds) && count($subtypeIds) > 0) { $subtypes = App\Models\jobsubtypes::whereIn('id', $subtypeIds)->get(); } else { $subtypes = collect(); } $alsoIs = []; if ($userJob && $userJob->also_is) { $alsoIs = json_decode($userJob->also_is, true); if (!is_array($alsoIs)) { $alsoIs = [$alsoIs]; } } @endphp @if ($userJob && $userJob->job_details && $userJob->job_details->job) @endif @endforeach
Name Position User Type Regulatory Body Registration Number SubType Action
{{ $user->user->name }} {{ $user->position }}
{{ $userJob->job_details->job }}
@foreach($alsoIs as $also) @php $alsoJob = App\Models\UserJob::find($also['job_id']); @endphp
{{ $alsoJob ? $alsoJob->job : 'Job ID: ' . $also['job_id'] }}
@endforeach
{{ optional($userJob->reg_body)->name ?: '—' }}
@foreach($alsoIs as $also) @php $alsoRegBody = App\Models\JobRegulatoryBody::find($also['regulatory_body_id']); @endphp
{{ $alsoRegBody ? $alsoRegBody->name : ($also['regulatory_body_id'] ? 'Reg Body ID: ' . $also['regulatory_body_id'] : '-') }}
@endforeach
{{ $userJob->reg_no ?: '—' }}
@foreach($alsoIs as $also)
{{ $also['reg_no'] ?: '—' }}
@endforeach
@foreach($alsoIs as $also) @php $alsoSubtypes = json_decode($also['subtypes'], true) ?? []; $alsoSubtypeObjects = !empty($alsoSubtypes) ? App\Models\jobsubtypes::whereIn('id', $alsoSubtypes)->get() : collect(); @endphp
@forelse($alsoSubtypeObjects as $subtypeObj) {{ $subtypeObj->subtype_name }} @empty — @endforelse
@endforeach
@csrf
@php // Get current head office ID $headOfficeId = $users->first() ? $users->first()->head_office_id : null; // Get all users with user_job_assign for this head office // but who are NOT in head_office_users table $locationUsers = []; if ($headOfficeId) { $locationUsers = App\Models\user_job_assign::where('head_office_id', $headOfficeId) ->get() ->filter(function($jobAssign) use ($headOfficeId) { // Check if this user is NOT in head_office_users for this head office $isHeadOfficeUser = App\Models\HeadOfficeUser::where('user_id', $jobAssign->user_id) ->where('head_office_id', $headOfficeId) ->exists(); return !$isHeadOfficeUser; }); } @endphp @forelse ($locationUsers as $jobAssign) @php $user = $jobAssign->user; $subtypeIds = json_decode($jobAssign->subtypes) ?? []; if (is_array($subtypeIds) && count($subtypeIds) > 0) { $subtypes = App\Models\jobsubtypes::whereIn('id', $subtypeIds)->get(); } else { $subtypes = collect(); } $alsoIs = []; if ($jobAssign->also_is) { $alsoIs = json_decode($jobAssign->also_is, true); if (!is_array($alsoIs)) { $alsoIs = [$alsoIs]; } } @endphp @if ($jobAssign->job_details && $jobAssign->job_details->job) @endif @empty @endforelse
Name Position User Type Regulatory Body Registration Number SubType Action
{{ $user->name ?? 'N/A' }} {{ $jobAssign->position ?? '—' }}
{{ $jobAssign->job_details->job }}
@foreach($alsoIs as $also) @php $alsoJob = App\Models\UserJob::find($also['job_id']); @endphp
{{ $alsoJob ? $alsoJob->job : 'Job ID: ' . $also['job_id'] }}
@endforeach
{{ optional($jobAssign->reg_body)->name ?: '—' }}
@foreach($alsoIs as $also) @php $alsoRegBody = App\Models\JobRegulatoryBody::find($also['regulatory_body_id']); @endphp
{{ $alsoRegBody ? $alsoRegBody->name : ($also['regulatory_body_id'] ? 'Reg Body ID: ' . $also['regulatory_body_id'] : '-') }}
@endforeach
{{ $jobAssign->reg_no ?: '—' }}
@foreach($alsoIs as $also)
{{ $also['reg_no'] ?: '—' }}
@endforeach
@forelse($subtypes as $subtype) {{ $subtype->subtype_name }} @empty @foreach($alsoIs as $also) @php $alsoSubtypes = json_decode($also['subtypes'], true) ?? []; $alsoSubtypeObjects = !empty($alsoSubtypes) ? App\Models\jobsubtypes::whereIn('id', $alsoSubtypes)->get() : collect(); @endphp @forelse($alsoSubtypeObjects as $subtypeObj) {{ $subtypeObj->subtype_name }} @empty @endforelse @endforeach @if (count($subtypes) === 0 && count($alsoIs) === 0) — @endif @endforelse
@csrf
No location users found