@extends('admin.layouts.app')


@section('content')

@if (session('video_update_msg'))
<div class="alert alert-success">
    {{ session('video_update_msg') }}
</div>
@endif

<h2 class="mb-3">{{awtTrans('Edit Video')}}</h2>

{!! Form::model($video, ['method' => 'PATCH', 'route' => ['admin.videos.update', $video->id], 'files' => true]) !!}
<div class="row">
    <div class="col-md-12">

        <div class="form-group">
            {!! Form::label('link', awtTrans('Video Link')) !!}
            {!! Form::text('link', null, ['class' => $errors->has('link') ? 'form-control is-invalid' : 'form-control']) !!}
            <small class="text-danger">{{ $errors->first('link') }}</small>
        </div>

    </div>
</div>


<div class="row">

    <div class="form-group col-lg-12">
        <button type="button" class="btn btn-info btn-block" id="add-keyword"><i class="fas fa-plus"></i></button>
    </div>
</div>

<div class="row" id="append-keyword">

    @if ($video->keywords->isNotEmpty())
    @foreach ($video->keywords as $key => $keyword)
    @if ($key == 0)

    <div class="row col-lg-12">

        <div class="form-group col-lg-5">
            <lable for="keyword_ar">الكلمات المفتاحية بالعربي</lable>
            <input type="text" name="keyword_ar[]" value="{{ $keyword->body_ar }}" class="form-control" />
        </div>

        <div class="form-group col-lg-5">
            <lable for="keyword_en">الكلمات المفتاحية بالانجليزي</lable>
            <input type="text" name="keyword_en[]" value="{{ $keyword->body_en }}" class="form-control" />
        </div>


    </div>

    @else

    <div class="row col-lg-12">


        <div class="form-group col-lg-5">
            <lable for="keyword_ar">الكلمات المفتاحية بالعربي</lable>
            <input type="text" name="keyword_ar[]" value="{{ $keyword->body_ar }}" class="form-control" />
        </div>

        <div class="form-group col-lg-5">
            <lable for="keyword_en">الكلمات المفتاحية بالانجليزي</lable>
            <input type="text" name="keyword_en[]" value="{{ $keyword->body_en }}" class="form-control" />
        </div>

        <div class="form-group col-lg-2">
            <lable for="keyword_en">حذف</lable>
            <button type="button" class="btn btn-danger btn-block" id="delete-keyword"><i class="fas fa-trash"></i></button>
        </div>

    </div>
    @endif
    @endforeach
    @endif
</div>



{!! Form::submit(awtTrans('Update Video'), ['class' => 'btn btn-success']) !!}
<a href="{{ route('admin.videos.index') }}" class="btn btn-primary"><i class="fas fa-arrow-left  fa-sm  "></i> {{awtTrans('Back')}}</a>

{!! Form::close() !!}

@endsection