@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="col">
                <form action="">
                    <div class="row">
                        <div class="col-4">
                            <input type="text" class="form-control" name="s" value="{{ request()->input('s') }}">
                        </div>
                        <div class="col">
                            <button class="btn btn-primary">搜尋</button>
                            <a class="btn btn-success text-white" href="{{ route('adm.client.create') }}">
                                <i class="bi bi-plus"></i>
                            </a>
                        </div>
                    </div>
                </form>

            </div>
        </div>

        <div class="row">
            <div class="col">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>名稱</th>
                            <th>專案數</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($clients->items() as $client)
                        <tr>
                            <td>{{ $client->id }}</td>
                            <td>{{ $client->name }}</td>
                            <td>{{ $client->projects()->count() }}</td>
                            <td>
                                <a href="{{ route('adm.client.show', [$client->id]) }}" class="btn btn-sm btn-primary">
                                    <i class="bi bi-eye"></i>
                                </a>
                                <a href="{{ route('adm.client.edit', [$client->id]) }}" class="btn btn-sm btn-outline-secondary">
                                    <i class="bi bi-pencil"></i>
                                </a>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
        <div class="row my-2">
            <div class="col">
                <div>共 {{ $clients->total() }} 筆，第 {{ $clients->currentPage() }} / {{ ceil($clients->total() / $clients->perPage()) }} 頁</div>
                <nav class="navigation">
                    <ul class="pagination">
                        <li class="page-item"><a class="page-link" href="{{ $clients->previousPageUrl() }}">&lt;</a></li>
                        <li class="page-item"><a class="page-link" href="{{ $clients->nextPageUrl() }}">&gt;</a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
@endsection
