@extends('store.layouts.container')

@section('content')
    <div class="side-title">
        <h3>{{ $head ?? ''}}</h3>
    </div>

    <div class="border-item">
        <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}" enctype="multipart/form-data">
            @csrf


            <div class="form-group col-lg-6">
                <label>{{ meta('email', getCurrentLocale()) ?? __('stores.email') }} </label>
                <input type="email" class="form-control {{ $errors->has('email') ? 'is-invalid' : '' }}" name="email" placeholder="{{ meta('email', getCurrentLocale()) ?? __('stores.email') }}" value='{{ old("email", $store->email ?? "") }}'/>
            </div>

            <div class="form-group col-lg-6">
                <label>{{ meta('phone', getCurrentLocale()) ?? __('stores.phone') }} </label>
                <input type="number" class="form-control {{ $errors->has('phone') ? 'is-invalid' : '' }}" name="phone" placeholder="{{ meta('phone', getCurrentLocale()) ?? __('stores.phone') }}" value='{{ old("phone", $store->phone ?? "") }}'/>
            </div>

            <div class="form-group col-lg-6">
                <label>{{ meta('password', getCurrentLocale()) ?? __('users.password') }} </label>
                <input type="password" class="form-control {{ $errors->has('password') ? 'is-invalid' : '' }}" name="password" placeholder="{{ meta('password', getCurrentLocale()) ?? __('users.password') }}" value='{{ old("password", "") }}'/>
            </div>

            <div class="form-group col-lg-6">
                <label>{{ meta('password_confirmation', getCurrentLocale()) ?? __('users.password_confirmation') }} </label>
                <input type="password" class="form-control {{ $errors->has('password_confirmation') ? 'is-invalid' : '' }}" name="password_confirmation" placeholder="{{ meta('password_confirmation', getCurrentLocale()) ?? __('users.password_confirmation') }}" value='{{ old("password_confirmation", "") }}'/>
            </div>

            @foreach($languages as $language)

                <div class="form-group col-lg-6">
                    <label>{{ meta('title', $language->local) ?? __('stores.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                    <input type="text" class="form-control {{ $errors->has('title_'.$language->local) ? 'is-invalid' : '' }}" name="title_{{ $language->local }}" placeholder="{{ meta('title', $language->local) ?? __('stores.title') }}" value='{{ old("title_{$language->local}", $store[$language->local]->title ?? "") }}'/>
                </div>

            @endforeach

            <div class="form-group col-lg-12">
                <label>{{   __('stores.brand_id') }} </label>
                <div class="clearfix"></div>
                <div class="row">
                    @foreach($brands as $key=> $row)
                        <div class="col-sm-4">
                            <div class="custom-control custom-checkbox">
                                <input type="checkbox" {{ in_array($row->id, $brand_ids) ? 'checked' : '' }} value="{{ $row->id }}" class="custom-control-input" id="brand_{{ $key }}" name="brand_ids[]">
                                <label class="custom-control-label" for="brand_{{ $key }}"> {{ $row->title }} </label>
                            </div>
                        </div>
                    @endforeach
                </div>
            </div>

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

@endsection

@section('inner_js')
    <!-- Editor JS orders -->
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>

    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            currentLanguage = "{{getCurrentLocale()}}",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
    <script src="{{ asset('assets/admin/js/articles.js') }}"></script>
@endsection



