<x-admin-panel-layout>
    <x-slot name="title">
        ویرایش اسلاید
    </x-slot>
    <x-slot name="main">
        <!-- Checked checkbox -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">ویرایش اسلاید </h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-left">
                            <li class="breadcrumb-item"><a href="{{ route("admin.dashboard") }}">داشبورد</a></li>
                            <li class="breadcrumb-item active">ویرایش اسلاید</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <section class="content mt-sm-3">
            <div class="card p-0 card-primary col-md-8 mx-auto">
                <div class="card-header">
                    <h3 class="card-title">ویرایش اسلاید</h3>
                </div>
                @if(session()->exists('status'))
                    <div class="alert alert-success col-md-11 mx-auto mt-2" role="alert" id="alertAddCategory">
                        ویرایش اسلاید موفقیت ایجاد گردید
                    </div>
            @endif

            <!-- /.card-header -->
                <!-- form start -->
                <form class="mt-3 p-2" action="{{route('slider.update',$slide->id)}}" method="post" enctype="multipart/form-data">
                    @csrf
                    @method('patch')
                    <div class="form-group">
                        <input type="text" name='title' class="form-control" id="title"
                               placeholder="عنوان اسلاید" value="{{old('title',$slide->title)}}" required>
                        @error('title')
                        <div class="invalid">
                            <p class="text-danger" style="font-size: 0.8rem;padding-right: 0.2rem">{{$message}}</p>
                        </div>
                        @enderror
                    </div>
                    <div class="form-group">
                        <input type="text" name='url' class="form-control" id="url"
                               placeholder="ادرس مربوطه (url)" value="{{old('url',$slide->route)}}" required>
                        @error('url')
                        <div class="invalid">
                            <p class="text-danger" style="font-size: 0.8rem;padding-right: 0.2rem">{{$message}}</p>
                        </div>
                        @enderror
                    </div>
                    <div class="form-group">
                        <select name="name" id="name" class="form-control">
                            <option selected hidden disabled>نوع اسلاید</option>
                            <option
                                @if($slide->name == \Mehrab\Slider\Models\Slider::MAIN) selected @endif
                                value="{{\Mehrab\Slider\Models\Slider::MAIN}}">@lang(\Mehrab\Slider\Models\Slider::MAIN)</option>
                            <option
                                @if($slide->name == \Mehrab\Slider\Models\Slider::MAIN_TINY) selected @endif
                            value="{{\Mehrab\Slider\Models\Slider::MAIN_TINY}}">@lang(\Mehrab\Slider\Models\Slider::MAIN_TINY)</option>
                            <option
                                @if($slide->name == \Mehrab\Slider\Models\Slider::INTRO) selected @endif
                            value="{{\Mehrab\Slider\Models\Slider::INTRO}} "> @lang(\Mehrab\Slider\Models\Slider::INTRO)</option>
                            <option
                                @if($slide->name == \Mehrab\Slider\Models\Slider::BRAND) selected @endif
                            value="{{\Mehrab\Slider\Models\Slider::BRAND}}">@lang(\Mehrab\Slider\Models\Slider::BRAND)</option>
                        </select>
                        @error('name')
                        <div class="invalid">
                            <p class="text-danger" style="font-size: 0.8rem;padding-right: 0.2rem">{{$message}}</p>
                        </div>
                        @enderror
                    </div>
                    <div class="form-group border mx-auto my-2">
                        <img src="{{$slide->thumb() ?? ''}}" style="width: 150px;height: 150px" />
                    </div>
                    <button type="submit" class="btn btn-primary btn-block mt-3">ویرایش</button>
                </form>
            </div>
        </section>
    </x-slot>
</x-admin-panel-layout>
