@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>Videos Gallery</h5>
                    </div>
                    <div class="col-md-3">
                        <a href="{{ route('gallery.create') }}" style="float: right;"
                            class="btn btn-primary btn-sm btn-rounded">Add Vide</a>
                    </div>
                </div>
                <div class="row mt-4">
                    <form method="POST" action="{{ route('video.update',$video->id) }}" enctype="multipart/form-data">
                        @method('put')
                        @csrf
                        <div class="col-md-12">
                            <div class="form-outline">
                                <input type="test" id="title" name="title" required value="{{ old('title') ?? $video->title }}"
                                    class="form-control" />
                                <label class="form-label" for="title">title</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <input type="text" id="video_url" name="video_url" required value="{{ $video->video_url }}"
                                    class="form-control" />
                                <label class="form-label" for="video_url">URL</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-2">
                            <select id="cat_id" type="text"
                                class="form-control select2 @error('cat_id') is-invalid @enderror" required name="cat_id">
                                <option value="">Choose Category</option>
                                @foreach ($categories as $row)
                                    <option value="{{ $row->id }}" @if($row->id==$video->category_id) {{ "selected" }} @endif>{{ $row->name_en }}</option>
                                @endforeach
                            </select>
                            @error('cat_id')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                        <div class="col-md-12 mt-2">
                            <select id="language_id" type="text"
                                class="form-control select2 @error('language_id') is-invalid @enderror" required
                                name="language_id">
                                <option value="">Choose Language</option>
                                @foreach ($language as $row)
                                    <option value="{{ $row->id }}" @if($row->id==)>{{ $row->name_en }}</option>
                                @endforeach
                            </select>
                            @error('cat_id')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <textarea cols="10" rows="4" id="body" name="body" required value="" class="form-control">{{ old('details') }}</textarea>
                                <label class="form-label" for="body">Description</label>
                            </div>
                        </div>
                        <div class="col-md-3 mt-2">
                            <button type="submit" class="btn btn-primary">
                                {{ __('Save') }}
                            </button>
                        </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");
      
        <?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
