<?php

use App\Services\Chapter4Service;
use Livewire\Component;

new class extends Component
{
    public $data = [];
    public $school;

    public function mount(Chapter4Service $srvs) {
        $this->data = $srvs->getUsers($this->school, 6);
    }
};
?>

<div>
    <div class="table-responsive">
        <table class="table table-bordered" id="myTableTchers" style="width: 100%">
            <thead>
                <tr>
                    <th class="text-center" style="width: 3%">N°</th>
                    <th class="text-center">Nom et Prénons</th>
                    <th class="text-center">Matrimonile</th>
                    <th class="text-center">Discipline</th>
                    <th class="text-center">Diplôme</th>
                    <th class="text-center">Contrat</th>
                    <th class="text-center">Volume Horaire</th>
                </tr>
            </thead>
            <tbody>
            @php $i = 1; @endphp
            @forelse ($data as $item)
                <tr>
                    <th class="text-center">{{ $i < 10 ? '0'.$i++:$i++ }}</th>
                    <td class="text-center">
                        {{ ($item->sexe == 'F' ? 'Mme':'Mr').' '.strtoupper($item->first_name).' '.ucwords($item->last_name) }}
                    </td>
                    <td>{{ ucwords($item->matrimoniale) }}</td>
                    <td>A definir</td>
                    <td>{{ ucwords($item->diplome ?? 'A definir') }}</td>
                    <td>{{ ucwords($item->embauche) }}</td>
                    <td>A definir</td>
                </tr> 
            @empty
                <tr>
                <td colspan="7" class="text-center">Underdefined data</td>
                </tr>
            @endforelse
            </tbody>
        </table>
    </div>
</div>