@extends('admin.pages.build')
@push('css')
    <link rel="stylesheet" href="/site/assets/vendors/simple-datatables/style.css">
@endpush
@section('content')
    <div class="table-responsive" style="background: #fff">
        <table id="dataTable" class="table data-table table-striped mb-0">
            <thead>
            <tr>
                <th>Başvuru No</th>
                <th>Ad Soyad</th>
                <th>Telefon Numarası</th>
                <th>İl</th>
                <th>İlçe</th>
                <th>Mahalle</th>
                <th>Sokak</th>
                <th>Bina No</th>
                <th>Kat</th>
                <th>Daire No</th>
                <th>Kişi İsimleri</th>
                <th>Kişi Telefonları</th>
                <th>Durum</th>
            </tr>
            </thead>
            <tbody>
            @foreach($needHomes as $needHome)
                <tr>
                    <td>#{{ $needHome->no }}</td>
                    <td>{{ $needHome->name }}</td>
                    <td>{{ $needHome->telephone }}</td>
                    <td>{{ $needHome->getCity->il_adi ?? '' }}</td>
                    <td>{{ $needHome->getTown->ilce_adi ?? '' }}</td>
                    <td>{{ $needHome->getDistrict->mahalle_adi ?? '' }}</td>
                    <td>{{ $needHome->getStreet->sokak_adi ?? '' }}</td>
                    <td>{{ $needHome->apartment_no }}</td>
                    <td>{{ $needHome->floor }}</td>
                    <td>{{ $needHome->apartment }}</td>
                    <td>
                        @foreach($needHome->getPersons as $key => $needHomePerson)
                            {{ $needHomePerson->name }} @if(array_key_last($needHome->getPersons->toArray()) != $key) / @endif <br>
                        @endforeach
                    </td>
                    <td>
                        @foreach($needHome->getPersons as $key => $needHomePerson)
                            {{ $needHomePerson->telephone }} @if(array_key_last($needHome->getPersons->toArray()) != $key) / @endif <br>
                        @endforeach
                    </td>
                    <td>{{ $needHome->status == 2 ? 'Bekliyor' : ($needHome->status == 1 ? 'Tamamlandı' : 'Reddedildi') }}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
@endsection
@push('js')
    <script src="/site/assets/vendors/simple-datatables/simple-datatables.js"></script>
    <script src="/site/assets/js/bootstrap.min.js"></script>
    <script>
        let dataTable = new simpleDatatables.DataTable("#dataTable");
    </script>
@endpush
