



<div class="card mb-2">

    <h5 class="card-header">
        {{ __('Bilder') }}

    </h5>



    <div class="card-body">

        @if($product->id>0)
        <style>
            .dz-message {
                margin: 2rem 0;
            }
            .default-style .dz-message {
                font-size: 1.1em;
            }
        </style>

        <div class="row">
            <div class="col-md-8 col-sm-6">

                <div class="row">
                @foreach($product->images as $image)
                    <div class="col-6 col-md-4  text-center" style="border: 1px solid #eee;">
                        <img class="img-fluid" alt="" src="{{ route('product_image', [$image->slug]) }}">
                        <br>
                        <a href="{{ route('admin_product_image_delete', [$image->id, $product->id]) }}" class="btn btn-sm btn-primary mt-2 mb-2" onclick="return confirm('Bild wirklich löschen?');">Bild löschen</a>
                        @if($image->active)
                            <a href="{{ route('admin_product_image_attribute', [$image->id, 'active', 0]) }}" class="btn btn-sm btn-default mt-2 mb-2"><span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span> <i class="far fa-sync"></i></a>
                        @else
                            <a href="{{ route('admin_product_image_attribute', [$image->id, 'active', 1]) }}" class="btn btn-sm btn-default mt-2 mb-2"><span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span> <i class="far fa-sync"></i></a>
                        @endif
                        <br>
                        <div class="input-group input-group-sm">
                            <div class="input-group-prepend">
                                <a href="{{ route('admin_product_image_attribute', [$image->id, 'pos', $image->pos - 1]) }}" class="btn btn-default"><i class="fas fa-chevron-left"></i></a>
                            </div>
                            <input type="text" class="form-control text-center" value="{{$image->pos}}">
                            <div class="input-group-append">
                                <a href="{{ route('admin_product_image_attribute', [$image->id, 'pos', $image->pos + 1]) }}" class="btn btn-default"><i class="fas fa-chevron-right"></i></a>

                            </div>
                        </div>
                    </div>
                @endforeach
                </div>
            </div>
            <div class="col-md-4  col-sm-6">
                <div class="card">
                    <div class="card-body">
                            <form method="POST" action="{{ route('admin_product_image_upload') }}" accept-charset="UTF-8" class="avatar" enctype="multipart/form-data">
                                @csrf
                                <input type="hidden" name="product_id" value="{{$product->id}}">
                                <div class="slim_holder text-center">
                                    <div class="slim" style="margin:20px auto;"
                                         data-label='<span class="text-green">Foto-Upload</span><br>(Datei suchen oder Drag & Drop)'
                                         data-fetcher="fetch.php"
                                         data-size="600,800"
                                         data-min-size="200,200"
                                         data-max-file-size="10"
                                         data-status-image-too-small="Bild zu klein<br>min. $0 Pixel"
                                         data-status-file-type="Ungültige Datei<br>bitte nur: $0"
                                         data-status-file-size="Die Datei ist zu groß<br>max. $0 MB"
                                         data-button-confirm-label="bestätigen"
                                         data-button-cancel-label="abbrechen"
                                         data-button-confirm-title="bestätigen"
                                         data-button-cancel-title="abbrechen"
                                         data-button-rotate-title="drehen"
                                         data-ratio="3:4">
                                        <input type="file" name="images[]" required />
                                    </div>

                                    <br>
                                    <button class="btn btn-primary" type="submit">Bild speichern</button>
                                </div>
                            </form>
                    </div>
                </div>
            </div>
        </div>
        @else
         <p>Produkt erst speichern</p>


        @endif


    </div>
</div>
