@php $formatContractType = fn ($contract): string => mb_strtoupper($contract->contract_type ?: 'cdi'); $contractTypeModifier = fn ($contract): string => $contract->contract_type === 'cdd' ? ' contract-type-badge--cdd' : ' contract-type-badge--cdi'; $statusBadgeModifier = fn ($contract): string => match ($contract->status) { 'draft' => ' contract-status-badge--draft', 'to_sign' => ' contract-status-badge--to-sign', 'cancelled' => ' contract-status-badge--cancelled', 'ended', 'superseded' => ' contract-status-badge--ended', default => '', }; $formatDates = function ($contract): string { $start = $contract->started_on?->format('d/m/y') ?? '—'; $end = $contract->ended_at ?? $contract->ends_on; if ($end) { return "{$start} → {$end->format('d/m/y')}"; } if (! $contract->started_on) { return $start; } $days = max(0, (int) $contract->started_on->diffInDays(now()) + 1); return $start.' ('.$days.' jour'.($days > 1 ? 's' : '').')'; }; $formatAmplitude = function ($contract): string { $schedule = is_array($contract->weekly_schedule) ? $contract->weekly_schedule : []; $days = collect($schedule)->where('enabled', true)->count(); $minutes = (int) ($contract->weekly_minutes ?? 0); if ($days === 0 && $minutes === 0) { return '—'; } $hours = $minutes / 60; $hoursLabel = fmod($hours, 1.0) === 0.0 ? (string) (int) $hours : str_replace('.', ',', rtrim(rtrim(number_format($hours, 2, '.', ''), '0'), '.')); return $days.'jrs | '.$hoursLabel.' hrs'; }; $contractUrl = fn ($contract): ?string => $isParentView ? route('parent.contracts.show', $contract) : route('contracts.show', $contract); $pdfUrl = fn ($contract): string => route($isParentView ? 'parent.contracts.pdf' : 'contracts.pdf', $contract); $canDelete = fn ($contract): bool => ! $isParentView && in_array($contract->status, ['draft', 'to_sign', 'cancelled'], true); $canAmend = fn ($contract): bool => $contract->status === 'active' && ! $contract->hasPendingAmendment(); $amendmentStoreUrl = fn ($contract): string => route($isParentView ? 'parent.contracts.amendments.store' : 'contracts.amendments.store', $contract); $sortUrl = function (string $column) use ($sort, $direction): string { $query = request()->except(['sort', 'direction', 'page']); if ($sort !== $column) { $query['sort'] = $column; $query['direction'] = 'asc'; } elseif ($direction === 'asc') { $query['sort'] = $column; $query['direction'] = 'desc'; } return request()->url().($query ? '?'.http_build_query($query) : ''); }; $sortIndicator = fn (string $column): string => $sort === $column ? ($direction === 'asc' ? '↑' : '↓') : ''; $tabUrl = fn (string $tab): string => $isParentView ? route('parent.contracts', ['tab' => $tab]) : route('contracts.index', ['tab' => $tab]); @endphp

Mes contrats

@if ($shareCode ?? null)
@endif
@if ($isParentView) @else @endif
@if ($activeTab === 'models') @if (($templates ?? collect())->isNotEmpty())
@foreach ($templates as $template) @php $templateUrl = route('contract-templates.edit', $template); @endphp @endforeach
Modèle Type Amplitude Salaire net estimé Dernier partage Actions
{{ $template->title }} {{ mb_strtoupper($template->contract_type) }} {{ $formatAmplitude($template) }} {{ $template->monthly_salary_estimate ? number_format((float) $template->monthly_salary_estimate, 2, ',', ' ') . ' €' : '—' }} {{ $template->shared_at?->diffForHumans() ?? 'Jamais' }}
@else
Je n’ai pas encore de modèle.

Mes modèles apparaîtront ici dès qu’ils seront créés.

Créer un modèle
@endif @elseif ($contracts->count() > 0)
@foreach ($contracts as $contract) @php $child = $contract->child; $employer = $child?->employer; $rowUrl = $contractUrl($contract); @endphp @endforeach
Enfant{{ $sortIndicator('child') }} Parent{{ $sortIndicator('parent') }} État{{ $sortIndicator('status') }} Type{{ $sortIndicator('type') }} Dates Amplitude Actions
@if ($rowUrl) {{ $child?->display_name ?? 'Mon enfant' }} @else {{ $child?->display_name ?? 'Mon enfant' }} @endif {{ $employer?->display_name ?: 'Parent non renseigné' }} {{ $contract->statusLabel() }} {{ $formatContractType($contract) }} {{ $formatDates($contract) }} {{ $formatAmplitude($contract) }}
{{ $contracts->links() }}
@else
Je n’ai pas encore de contrat.

Mes contrats apparaîtront ici dès qu’ils seront créés.

@if ($isParentView) Créer un contrat @else Créer un contrat @endif
@endif