@extends('admin.layouts.container')

@section('content')

<div class="side-title">
    <h3>{{ $head ?? '' }}</h3>
</div>

<div class="border-item">
    <form class="form-row" method="post" action="{{ $action }}" enctype="multipart/form-data">
        @if($package ?? ''  && $package->id)
            @method('PUT')
        @endif
        @CSRF

 @foreach($language as $lang)
        <div class="form-group col-lg-6">
            <label>The Name {{$lang->local}} </label>
            @php 
            $error_name ='package.'.$lang->local.'.name';
            $error_description ='package.'.$lang->local.'.description';
              @endphp
            <input type="text" class="form-control {{ $errors->has($error_name) ? 'is-invalid' : '' }}" name="package[{{$lang->local}}][name]"placeholder="{{ meta('name', getCurrentLocale()) ??__('packages.name') }}"@if($package ?? '' && $package->id) value="{{packagelangname($package->id ,$lang->id)}}" @else value='{{old("$error_name")}}' @endif/>
            <input type="hidden" name="package[{{$lang->local}}][language_id]" value="{{$lang->id}}">
        </div>

        <div class="form-group col-lg-6">
            <label>The Description {{$lang->local}} </label>
            <input type="text" class="form-control {{ $errors->has($error_description) ? 'is-invalid' : '' }}" name="package[{{$lang->local}}][description]" placeholder="{{ meta('description', getCurrentLocale()) ??__('packages.description') }}" @if($package ?? ''  && $package->id) value="{{packagelangdescription($package->id ,$lang->id) }}" @else value='{{ old("$error_name")}}' @endif />
        </div>


    @endforeach


          <div class="form-group col-lg-6">
            <label>{{ meta('cost', getCurrentLocale()) ?? __('packages.cost') }} </label>
            <input type="number" min="0" class="form-control  {{ $errors->has('cost') ? 'is-invalid' : '' }}" name="cost" placeholder="{{ meta('cost', getCurrentLocale()) ??__('packages.cost') }}" value='{{ old("cost", $package->cost ?? "") }}'/>
            
        </div>
          <div class="form-group col-lg-6">
            <label>{{ meta('img', getCurrentLocale()) ?? __('packages.img') }} </label>
            <input type="file" class="form-control  {{ $errors->has('img') ? 'is-invalid' : '' }}" name="img" id="img" placeholder="{{ meta('img', getCurrentLocale()) ??__('packages.img') }}" value='{{ old("img") }}'/>
            
        </div>

        <div class="text-center mt-5 col-12">
            <button class="butn"><span>{{ __('site.save') }}</span></button>
        </div>
    </form>
</div>

@endsection

@section('inner_js')
    <!-- Editor JS files -->
{{--    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>--}}
            <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
@endsection
