<x-master-layout>
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <div class="card card-block card-stretch">
                    <div class="card-body p-0">
                        <div class="d-flex justify-content-between align-items-center p-3">
                            <h5 class="font-weight-bold">{{ $pageTitle ?? __('message.list') }}</h5>
                            <a href="{{ route('clientreview.create') }}"class="float-right btn btn-sm btn-primary jqueryvalidationLoadRemoteModel">{{ __('message.add_form_title', ['form' => __('message.review')]) }}</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">
                        {{ Form::open(['method' => 'POST', 'route' => ['frontend.website.information.update', 'client_review'], 'id' => 'clientreview_form', 'enctype' => 'multipart/form-data']) }}
                        <div class="row">
                            @foreach ($clientreview as $key => $value)
                                @if (in_array($key, ['client_review_title']))
                                    <div class="col-md-6 form-group">
                                        {{ Form::label($key, __('message.' . $key) . ' <span class="text-danger">*</span>', ['class' => 'form-control-label'], false) }}
                                        {{ Form::text($key, $value ?? null, ['placeholder' => __('message.' . $key), 'class' => 'form-control', 'required' => true]) }}
                                    </div>
                                @endif
                            @endforeach
                        </div>
                        <hr>
                        <div class="col-md-12 mt-1 mb-4">
                            <button class="btn btn-md btn-primary float-md-right" id="saveButton">{{ __('message.save') }}</button>
                        </div>
                        {{ Form::close() }}
                    </div>
                    @if (count($data) > 0)
                        @include('clientreview.list')
                    @else
                    @endif
                    <br>
                </div>
            </div>
        </div>
    </div>
    @section('bottom_script')
        <script>
            $(document).ready(function() {
                $("#clientreview_form").validate({
                    rules: {
                        'value[]': {
                            required: true
                        }

                    },
                    messages: {
                        'value[]': {
                            required: "{{ __('message.please_enter_title') }}"
                        }
                    },
                    errorPlacement: function(error, element) {
                        error.addClass('text-danger');
                        error.insertAfter(element);
                    },
                    highlight: function(element, errorClass, validClass) {
                        $(element).addClass('is-invalid');
                        $(element).removeClass('is-valid');
                    },
                    unhighlight: function(element, errorClass, validClass) {
                        $(element).removeClass('is-invalid');
                        $(element).addClass('is-valid');
                    }
                });
            });
        </script>
    @endsection
</x-master-layout>
