@extends('layouts.app')
@section('title', '駐輪規定マスタ')

@section('content')
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-lg-6">
                    <h1 class="m-0 text-dark">駐輪規定マスタ</h1>
                </div>
                <div class="col-lg-6">
                    <ol class="breadcrumb float-sm-right text-sm">
                        <li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
                        <li class="breadcrumb-item active">駐輪規定マスタ</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>

    <section class="content">
        <div class="container-fluid">
            @if ($errors->any())
                <div class="alert alert-danger">
                    @foreach ($errors->all() as $e)
                        <div>{{ $e }}</div>
                    @endforeach
                </div>
            @endif
            @if (session('success'))
                <div class="alert alert-success">{{ session('success') }}</div>
            @endif

            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">駐輪場情報</h3>

                </div>
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div style="width:180px;" class="font-weight-bold">
                            駐輪場名
                        </div>
                        <div class="ml-3">
                            {{ $park->park_name ?? '' }}
                        </div>
                    </div>
                </div>

            </div>
                <div class="d-flex justify-content-between align-items-center mb-2">

                <a href="{{ route('parking_regulations_add', ['park_id' => $parkId]) }}" class="btn btn-primary mr-2">新規</a>
                {{-- 件数 + ページネーション --}}
                <div class="d-flex justify-content-between align-items-center mb-3 px-3 pt-3">
                <div class="text-right ml-auto">
                    <div>
                        全 {{ $regulations->total() }} 件中
                        {{ $regulations->firstItem() }}〜{{ $regulations->lastItem() }} 件を表示
                    </div>
                    <div>
                        {{ $regulations->appends(request()->query())->links('pagination') }}
                    </div>
                </div>
                </div>
            </div>



                <div class="table-responsive">
                    <table class="table table-bordered table-sm">
                        <thead class="thead-light">
                            <tr>
                                <th style="width:100px">操作</th>
                                <th style="width:15%">車種区分</th>
                                <th style="width:15%">駐輪分類</th>
                                <th>駐輪規定</th>
                            </tr>
                        </thead>
                        <tbody style="background:#fff;">
                            @forelse($regulations as $r)
                                <tr>
                                    <td class="text-center align-middle">
                                        <a href="{{ route('parking_regulations_edit', ['seq' => $r->parking_regulations_seq]) }}" class="btn btn-sm btn-outline-primary">編集</a>
                                        <form method="POST" action="{{ route('parking_regulations_delete') }}" style="display:inline">
                                            @csrf
                                            <input type="hidden" name="parking_regulations_seq" value="{{ $r->parking_regulations_seq }}">
                                        </form>
                                    </td>
                                    <td>{{ $r->psection_subject ?? $r->psection_id }}</td>
                                    <td>{{ $r->ptype_subject ?? $r->ptype_id }}</td>
                                    <td class="regulations-html">{!! $r->regulations_text !!}</td>
                                </tr>
                            @empty
                                <tr>
                                    <td colspan="4" class="text-center text-muted">規定がありません。</td>
                                </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>

                <div class="mt-2">
                    {{ $regulations->appends(request()->query())->links('pagination') }}
                </div>

        </div>
    </section>
@endsection
