@php $member = (isset($data) && $data instanceof \Illuminate\Database\Eloquent\Model) ? $data : ((isset($dataTypeContent) && $dataTypeContent instanceof \Illuminate\Database\Eloquent\Model) ? $dataTypeContent : null); $memberId = $member ? $member->id : null; $availableCompanies = \App\Models\Company::orderBy('name')->get(); $maxCompanies = $availableCompanies->count(); // Load existing roles for this member $existingRoles = $memberId ? \App\Models\TeamCompanyRole::where('employee_id', $memberId)->orderBy('display_order')->get() : collect(); @endphp @if(isset($view) && ($view === 'browse' || $view === 'read')) {{-- Browse / Read Table View: Render structured table of Company Affiliations & Designations --}} @if($existingRoles->isNotEmpty())
@foreach($existingRoles as $r) @endforeach
Company Designation
{{ $r->company_name }} {{ $r->designation }}
@elseif($member && (!empty($member->company_working_with) || !empty($member->designation))) @php $rawComps = !empty($member->company_working_with) ? array_filter(array_map('trim', explode(',', $member->company_working_with))) : ['Farmers For Forests']; $defaultDesig = !empty($member->designation) ? $member->designation : '—'; @endphp
@foreach($rawComps as $comp) @endforeach
Company Designation
{{ $comp }} {{ $defaultDesig }}
@else No company affiliations @endif @else {{-- Edit / Add View: Interactive Multi-Company Repeater --}}
0 / {{ $maxCompanies }} Companies

Assign this member to one or more companies with their company-specific designation (e.g. Director, President, Trustee). Limited to the {{ $maxCompanies }} companies in the database, with no duplicates allowed.

{{-- Rows Container --}}
@if($existingRoles->isNotEmpty()) @foreach($existingRoles as $idx => $role)
@endforeach @endif
{{-- Empty State Notification --}}
No companies assigned yet. Click + Add Company below to assign a company and role.
{{-- Action Bar --}}
{{-- JavaScript for Duplicate Prevention and Max Limit Handling --}} @endif