@extends('back-end.master.app')
@section('title', 'Gallery')

@section('body')
    <main class="app-content">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-9">
                        <h5>galleries</h5>
                    </div>
                    <div class="col-md-3">
                        <a href="{{ route('gallery.create') }}" style="float: right;"
                            class="btn btn-primary btn-sm btn-rounded">Add Gallery</a>
                    </div>
                </div>
                <div class="row mt-4">
                    <form method="POST" action="{{ route('gallery.store') }}" enctype="multipart/form-data">
                        @csrf

                        <div class="form-group row">
                            <label for="title"
                                class="col-md-4 col-form-label text-md-right">{{ __('Image Title') }}</label>

                            <div class="col-md-6">
                                <input id="title" type="text"
                                    class="form-control @error('title') is-invalid @enderror" name="title"
                                    value="{{ old('title') }}" required autocomplete="title" autofocus>

                                @error('title')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>


                        <div class="form-group row">
                            <label for="image" class="col-md-4 col-form-label text-md-right">{{ __('image') }}</label>

                            <div class="col-md-6">
                                <input id="image" type="file"
                                    class="form-control @error('image') is-invalid @enderror" name="image">

                                @error('image')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-md-4 col-form-label text-md-right">&nbsp;</label>
                            <div class="col-md-6">
                                <div class="animated-checkbox">
                                    <label>
                                        <input type="checkbox" name="isSlider" id="isSlider"><span class="label-text">Show
                                            in Slider</span>
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-0">
                            <div class="col-md-6 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    {{ __('Save') }}
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </main>


@endsection


@section('pageJs')
    <script type="text/javascript">
        $(".app-menu").removeClass("active");
        $("#nav_gallery").addClass("active");
        $("#nav_galleryi").addClass("is-expanded");
        $("#nav_sub_gallery_list").addClass("active");
        $(document).on("click", ".btn-delete", function() {
            var id = $(this).attr("data-id");
            swal({
                title: "Are you sure want to delete?",
                text: "...",
                type: "warning",
                showCancelButton: true,
                confirmButtonText: "Yes!",
                cancelButtonText: "No!",
                closeOnConfirm: false,
                closeOnCancel: false
            }, function(isConfirm) {
                if (isConfirm) {
                    $('#delete-form').attr('action', "/admin/gallery/" + id);
                    $("#delete-form").submit();
                } else {
                    swal("Cancelled", "Record not deleted", "error");
                    return false;
                }
            });
        });
        <?php
if (session()->has("msg")) {
    ?>

        $.notify({
            title: "Notice: ",
            message: "<?= session()->get('msg') ?>",
            icon: "fa fa-check"
        }, {
            type: "success"
        });
        <?php
}
if ($errors->any()) {
    echo "$('#userModal').modal('show');";
}
?>
    </script>
@endsection
