@extends('admin.master')

@section('title')
    Video Gallery
@endsection

@section('content')
    <!--begin::Card-->
    <div class="card card-custom gutter-b example example-compact card-collapsed" data-card="true" id="kt_card_4">
        <div class="card-header">
            <h3 class="card-title">
                Add New Video
            </h3>
            <div class="card-toolbar">
                <a href="#" class="btn btn-icon btn-sm btn-light-primary mr-1" data-card-tool="toggle">
                    <i class="ki ki-arrow-down icon-nm"></i>
                </a>
            </div>
        </div>

        <form class="form" action="{{ route('videogalleries.store') }}" method="POST" enctype="multipart/form-data">
            @csrf
            <div class="card-body">
                <div class="form-group row">
                    <div class="col-lg-12">
                        <label>Video Link: <span class="text-danger">*</span></label>
                        <input type="text" name="link" class="form-control mb-2" placeholder="Enter video link here" value="{{ old('link') }}" required />
                        @error('link')
                            <span class="text-danger">{{ $message }}</span>
                        @enderror
                    </div>
                </div>


            </div>
            <div class="card-footer">
                <div class="row">
                    <div class="col-lg-12 text-center">
                        <button type="submit" class="btn btn-success mr-2">Add New Video</button>
                    </div>
                </div>
            </div>
        </form>

    </div>
    <!--end::Card-->

    <!--begin::Card-->
    <div class="card card-custom">
        <div class="card-header flex-wrap py-5">
            <div class="card-title">
                <h3 class="card-label">
                    Video Lists
                </h3>
            </div>
        </div>

        <div class="card-body">
            <!--begin: Datatable-->
            @if ($videoGalleries->isEmpty())
                <p>No videos found.</p>
            @else
                <table class="table table-separate table-head-custom table-checkable" id="kt_datatable1">
                    <thead>
                        <tr>
                            <th></th>
                            <th>ID</th>
                            <th>Video Link</th>
                            <th>Actions</th>
                        </tr>
                    </thead>

                    <tbody>
                        @foreach ($videoGalleries as $item)
                            <tr>
                                <td></td>
                                <td>{{ $item->id }}</td>
                                <td>{{ $item->link }}</td>
                                <td>
                                    <span style="display: inline-block;">
                                        <a href="{{ route('videogalleries.edit', $item->id) }}" class="btn btn-sm btn-clean btn-icon btn-icon-md" title="Edit"><i class="la la-edit"></i></a>
                                    </span>

                                    <span style="display: inline-block;">
                                        <form action="{{ route('videogalleries.destroy', $item->id) }}" method="POST" onsubmit="return confirm('Are you sure want to delete?')">
                                            @csrf
                                            @method('DELETE')
                                            <button class="btn btn-sm btn-clean btn-icon btn-icon-md" title="Delete"><i class="la la-trash"></i></button>
                                        </form>
                                    </span>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
                <!--end: Datatable-->
            @endif
        </div>
    </div>
@endsection
