<x-dashboard.layout :title="__('dashboard.edit_before_after')">

    <!-- Page Header -->
    <x-dashboard.partials.page-header :header="__('dashboard.edit_before_after')" :label_url="route('dashboard.before-afters.index')" :label="__('dashboard.before_afters')" />
    <!-- End Page Header -->


    <!-- Row-->
    <div class="row">
        <div class="col-sm-12 col-xl-12 col-lg-12">
            <div class="card custom-card overflow-hidden">
                <div class="card-header">
                    <h4 class="card-title">{{ __('dashboard.edit_before_after') }}</h4>
                </div>

                <div class="card-body">

                    <form action="{{ route('dashboard.before-afters.update', [$beforeAfter->id]) }}" method="POST"
                        enctype="multipart/form-data">
                        @csrf
                        @method('PATCH')
                        <div class="row">

                            <div class="form-group col-md-6">
                                <label>{{ __('dashboard.before_image') }} (max 5mb)</label>
                                <input type="file" class="form-control" name="before_image">
                                @error('before_image')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group col-md-6">
                                <label>{{ __('dashboard.after_image') }} (max 5mb)</label>
                                <input type="file" class="form-control" name="after_image">
                                @error('after_image')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group col-md-6 mt-3">
                                <label for="">{{ __('dashboard.before_image') }}</label>
                                @if ($beforeAfter->before_image)
                                    <img src="{{ $beforeAfter->before_image_path }}" width="250" class="img-thumbnail">
                                @else
                                    <p class="text-muted">لا توجد صورة</p>
                                @endif
                            </div>

                            <div class="form-group col-md-6 mt-3">
                                <label for="">{{ __('dashboard.after_image') }}</label>
                                @if ($beforeAfter->after_image)
                                    <img src="{{ $beforeAfter->after_image_path }}" width="250" class="img-thumbnail">
                                @else
                                    <p class="text-muted">لا توجد صورة</p>
                                @endif
                            </div>

                            <div class="form-group col-md-2">
                                <label>{{ __('dashboard.order') }}</label>
                                <input class="form-control" name="order" type="number"
                                    value="{{ old('order', $beforeAfter->order) }}"
                                    placeholder="{{ __('dashboard.order') }}">
                                @error('order')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group col-md-4 mt-3 mb-3">
                                <div class="d-flex flex-wrap gap-2">
                                    <h5 class="font-size-14 mb-3">{{ __('dashboard.publish/unpublish') }} </h5>
                                    <input type="checkbox" id="switch1" switch="none" value="1" name="status"
                                        @checked(old('status', $beforeAfter->status)) />
                                    <label for="switch1" data-on-label="{{ __('dashboard.yes') }}"
                                        data-off-label="{{ __('dashboard.no') }}"></label>
                                </div>
                            </div>

                            <div class="form-group col-md-12">
                                <button type="submit" class="btn btn-success"><i class="icon-note"></i>
                                    {{ __('dashboard.save') }} </button>
                                <a href="{{ route('dashboard.before-afters.index') }}"><button type="button"
                                        class="btn btn-danger mr-1"><i class="icon-trash"></i>
                                        {{ __('dashboard.cancel') }}</button></a>
                            </div>

                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- End Row -->

</x-dashboard.layout>

