@extends('backend.admin.layouts.app')
@section('content')
    <div class="pagetitle">
        <h1>Dashboard</h1>
        <nav>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                <li class="breadcrumb-item">Dashboard</li>
                <li class="breadcrumb-item active">{{ $PageTitle }}</li>

            </ol>
        </nav>
    </div><!-- End Page Title -->

    <section class="section dashboard">
        <div class="row">
            <div class="col-lg-8">

                <div class="card">
                    <div class="card-body mt-3">
                        <form action="{{ route('admin.slider.update', $slider->id) }}"
                              method="POST"
                              enctype="multipart/form-data">
                            @csrf
                            @method('PUT')

                            {{-- Banner Image --}}
                            <div class="row mt-5 mb-4">
                                <label for="image" class="col-sm-3 col-form-label">Banner Image</label>
                                <div class="col-sm-8 mb-25">
                                    <div class="upload-img-box">
                                        @if($slider->image)
                                            <img src="{{ asset('storage/' . $slider->image) }}"
                                                 alt="{{ $slider->alt ?? 'Slider image' }}">
                                        @else
                                            <img src="" alt="">
                                        @endif
                                            <input type="file" name="image" id="image"
                                                accept="image/*" onchange="previewFile(this)">
                                        <div class="upload-img-box-icon">
                                            <i class="fa-solid fa-camera"></i>
                                        </div>
                                    </div>
                                    <p class="col-sm-10 mt-2">Size: 950 x 400 (100kb)</p>
                                </div>
                            </div>

                            {{-- Type --}}
                            <div class="row mb-3">
                                <label for="image_type" class="col-sm-3 col-form-label">Type</label>
                                <div class="col-sm-9">
                                    <select class="form-select"
                                            id="image_type"
                                            name="type"
                                            aria-label="Default select example">
                                        <option value="">Select type</option>
                                        <option value="large" {{ $slider->type === 'large' ? 'selected' : '' }}>Large</option>
                                        <option value="small" {{ $slider->type === 'small' ? 'selected' : '' }}>Small</option>
                                    </select>
                                </div>
                            </div>

                            {{-- Alt Text --}}
                            <div class="row mb-3">
                                <label for="img_ifo" class="col-sm-3 col-form-label">Image Alternative Info</label>
                                <div class="col-sm-9">
                                    <input type="text"
                                           class="form-control @error('img_ifo') is-invalid @enderror"
                                           value="{{ old('img_info', $slider->alt) }}"
                                           name="img_info"
                                           id="img_ifo"
                                           placeholder="image alternative info">
                                </div>
                            </div>

                            <div class="row mb-3">
                                <div class="col-sm-10">
                                    <button type="submit" class="btn btn-primary">Save</button>
                                </div>
                            </div>

                        </form><!-- End General Form Elements -->

                    </div>
                </div>

            </div>
        </div>
    </section>
@endsection

@push('style')
    <style>
        .upload-img-box {
            width: 100%;
            height: 250px;
        }
    </style>
@endpush
