@extends('back-end.master.app')
@section('title', 'Gallery')
@section('pageCSS')
    <style>
        iframe {
            width: 100%;
            height: 200px;
        }
    </style>
@endsection
@section('body')
    <main class="app-content">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-9">
                        <h5>Videos galleries</h5>
                    </div>
                    <div class="col-md-3">
                        <a href="{{ route('video.create') }}" style="float: right;"
                            class="btn btn-primary btn-rounded btn-sm btn-sm btn-rounded btn-sm btn-rounded">Add Video</a>
                    </div>
                </div>
                <div class="row mt-4">
                    @foreach ($videos as $row)
                        <div class="col-md-4">

                            <div class="card">
                                <div class="card-header">
                                    <h5>{{ $row->title }}</h5>
                                </div>
                                <div class="card-body">
                                    @php
                                        $url = $row->url;
                                        $whitelist = ['YouTube', 'Vimeo', 'FaceBook'];
                                        $params = [
                                            'autoplay' => 1,
                                            'loop' => 1,
                                        ];
                                        $attributes = [
                                            'type' => null,
                                            'class' => 'iframe-class',
                                            'data-html5-parameter' => true,
                                        ];
                                        echo LaravelVideoEmbed::parse($url, $whitelist);
                                    @endphp
                                </div>
                                <div class="card-footer text-center">
                                    <a href="{{ route('video.edit', $row->id) }}"
                                        class="btn btn-primary btn-rounded btn-sm"><i class="fa fa-edit"></i>Edit</a>
                                    <a href="{{ route('video.delete', $row->id) }}"
                                        class="btn btn-danger btn-rounded btn-sm"><i class="fa fa-trash"></i>Delete</a>
                                </div>
                            </div>



                        </div>
                    @endforeach
                </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
