@extends('admin.layouts.app')


@section('content')

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

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

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

    <div class="row">
            <div class="form-group col-md-6">
                {!! Form::label('title_ar', awtTrans('Title Arabic')) !!}
                {!! Form::text('title_ar', null, ['class' => $errors->has('title_ar') ? 'form-control is-invalid' : 'form-control']) !!}
                <small class="text-danger">{{ $errors->first('title_ar') }}</small>
            </div>

            <div class="form-group col-md-6">
                {!! Form::label('title_en', awtTrans('Title English')) !!}
                {!! Form::text('title_en', null, ['class' => $errors->has('title_en') ? 'form-control is-invalid' : 'form-control']) !!}
                <small class="text-danger">{{ $errors->first('title_en') }}</small>
            </div>
        </div>


        <div class="row">

            <div class="form-group col-lg-12">
                {!! Form::label('photo', awtTrans('الصورة')) !!}
                <div class="input-group">
                    <span class="input-group-btn">
                        <a id="lfm" data-input="photo" data-preview="holder" class="btn btn-secondary text-white px-4" style="border-top-right-radius: 0;border-bottom-right-radius: 0;border-top-left-radius: 0;border-bottom-left-radius: 0;">
                            <i class="fa fa-picture-o"></i> {{ awtTrans('اختر الصورة') }}
                        </a>
                    </span>
                    {!! Form::text('photo', null, ['class' => $errors->has('photo') ? 'form-control is-invalid' : 'form-control' , 'readonly' => 'readonly']) !!}
                </div>
                <div class="mb-3 mt-3 d-block slider-holder" id="holder">
                    <img width="100" src="http://127.0.0.1:8000/storage/1/th.jpeg" alt="">
                </div>
                <small class="text-danger">{{ $errors->first('photo') }}</small>
            </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 ($manufacturing_stage->keywords->isNotEmpty())
            @foreach ($manufacturing_stage->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>


    </div>
</div>


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

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

@endsection