{{-- One grid cell. Expects: $row, $name, $col (['sql' => ?string]), $grid, $editUrl (closure row => url) --}} @php $value = $col['sql'] ? ($row->{$name} ?? null) : ($row->_activity->{$name} ?? null); $str = is_null($value) ? '' : (string) $value; @endphp @switch(true) @case($name === 'contact_name' || ($name === 'company' && $grid->module === 'contact')) {{ $str !== '' ? \Illuminate\Support\Str::limit($str, 40) : '(no name)' }} @break @case($name === 'subject') @php($aid = $col['sql'] ? ($row->activity_id ?? null) : ($row->_activity->activity_id ?? null)) @if ($str !== '' && $aid && Route::has('activities.show')) {{ $str }} @else {{ $str !== '' ? $str : '—' }} @endif @break @case($name === 'status') @php($tone = match (strtolower($str)) { 'completed' => 'badge-green', 'in progress' => 'badge-amber', 'not started' => 'badge-blue', default => 'badge-gray' }) @if ($str !== ''){{ $str }}@else—@endif @break @case($name === 'zoho_update') @if ($str !== ''){{ $str }}@else—@endif @break @case($name === 'DndStatus') @php([$label, $tone] = \App\Services\Crm\ContactFields::dndStatus($value)) {{ $label }} @break @case($name === 'MessageStatusId') @php([$label, $tone] = \App\Services\Crm\ContactFields::messageStatus($str)) @if ($tone){{ $label }}@else—@endif @break @case(in_array($name, ['data_allocation_date', 'due_date', 'DATA_ALOT_DATE_NEW'], true) && preg_match('/^\d{4}-\d{2}-\d{2}/', $str)) @if (str_starts_with($str, '1970-01-01')) Unallocated @else {{ date('d-m-Y', strtotime($str)) }} @endif @break @case(in_array($name, ['created_date', 'modified_by'], true) && preg_match('/^\d{4}-\d{2}-\d{2} \d/', $str)) {{ date('d-m-Y H:i', strtotime($str)) }} @break @case(in_array($name, ['mobile', 'other_phone', 'id', 'loan_id', 'activity_id', 'contact_id', 'car_reg_no'], true)) {{ $str !== '' ? $str : '—' }} @break @default @if ($str === '') — @elseif (mb_strlen($str) > 45) {{ \Illuminate\Support\Str::limit($str, 45) }} @else {{ $str }} @endif @endswitch