@extends('admin.layout') @section('content')

{{ translate('Edit product') }}

@php $currency_name = currency_sympol()['name']; @endphp
{!! Form::open(['method' => 'POST', 'id' => 'choice_form', 'action' => ['Admin\ProductController@updateRestorant', $product->id], 'files' => true, 'class' => 'form_to_submit']) !!}

{{ translate('basic information') }}

{!! Form::text('title', getTranslation($product, 'product_translations', 'title'), ['required' => 'required', 'class' => 'form-control', 'placeholder' => translate('Title')]) !!}
@error('title')
{{ $message }}
@enderror
{!! Form::text('sku', $product->sku, ['required' => 'required', 'class' => 'form-control', 'placeholder' => translate('sku')]) !!}
@error('sku')
{{ $message }}
@enderror
{!! Form::text('arrangement', $product->arrangement, ['required' => 'required', 'class' => 'form-control', 'placeholder' => translate('arrangement')]) !!}
@error('sku')
{{ $message }}
@enderror
@if (Session::get('tenant_subscribtion_data')['product_label']['belongs_to_subscribtion'] == true && Session::get('tenant_controle_modules')['product_label'] == 1)
{!! Form::text('label_text', getTranslation($product, 'product_translations', 'label_text'), ['class' => 'form-control', 'placeholder' => translate('Label text')]) !!}
@error('label_text')
{{ $message }}
@enderror
{!! Form::color('label_color', getTranslation($product, 'product_translations', 'label_color'), ['class' => 'form-control', 'placeholder' => translate('Label color')]) !!}
@error('label_color')
{{ $message }}
@enderror
@endif
@error('category_id')
{{ $message }}
@enderror
{!! Form::checkbox('published', null, $product->published, ['id' => 'Checkbox_2']) !!}
{!! Form::checkbox('require_charge', $product->require_charge, 0, ['id' => 'require_charge_2']) !!}
{!! Form::textarea('short_desc', getTranslation($product, 'product_translations', 'short_desc'), ['required' => 'required', 'class' => 'form-control', 'placeholder' => translate('Short description')]) !!}
@error('short_desc')
{{ $message }}
@enderror
{!! Form::textarea('description', getTranslation($product, 'product_translations', 'description'), ['id' => 'e1', 'class' => 'form-control', 'placeholder' => translate('Description')]) !!}
@error('description')
{{ $message }}
@enderror
{!! Form::text('tags', getTranslation($product, 'product_translations', 'tags'), ['style' => 'width:100%', 'data-role' => 'tagsinput', 'class' => 'form-control', 'placeholder' => translate('Tags')]) !!}
@error('tags')
{{ $message }}
@enderror
{!! Form::checkbox('refundable', null, $product->refundable, ['id' => 'refundable_2']) !!}

{{ translate('price + stock') }}

{!! Form::number('unit_price', $product->unit_price, ['min' => '0', 'step' => '0.01', 'required' => 'required', 'class' => 'form-control', 'placeholder' => translate('Unit price')]) !!}
{{ $currency_name }}
@error('unit_price')
{{ $message }}
@enderror
{!! Form::number('cost_price', $product->cost_price, ['min' => '0', 'step' => '0.01', 'required' => 'required', 'class' => 'form-control', 'placeholder' => translate('Cost Price')]) !!}
{{ $currency_name }}
@error('cost_price')
{{ $message }}
@enderror
{!! Form::number('market_price', $product->market_price, ['min' => '0', 'step' => '0.01', 'required' => 'required', 'class' => 'form-control', 'placeholder' => translate('Cost Price')]) !!}
{{ $currency_name }}
@error('market_price')
{{ $message }}
@enderror
{!! Form::number('current_stock', $product->current_stock, ['id' => 'current_stock_id', 'min' => '0', 'step' => '1', 'required' => 'required', 'class' => 'form-control', 'placeholder' => translate('Quantity')]) !!}
@error('current_stock')
{{ $message }}
@enderror
{!! Form::checkbox('current_stock_unlimited', null, $product->current_stock_unlimited, ['id' => 'Checkboxs_12']) !!}
{!! Form::number('weight', $product->weight, ['min' => '0', 'step' => '1', 'required' => 'required', 'class' => 'form-control', 'placeholder' => translate('Weight')]) !!}
@error('weight')
{{ $message }}
@enderror
{!! Form::select('measruing_unit', ['kg' => 'KG', 'g' => 'G', 'lb' => 'LB'], $product->measruing_unit, ['class' => 'form-control ']) !!}
{!! Form::number('discount', $product->discount, ['min' => '0', 'step' => '0.01', 'class' => 'form-control', 'placeholder' => translate('Discount')]) !!}
@error('discount')
{{ $message }}
@enderror
{!! Form::select('discount_type', ['amount' => translate('Amount'), 'percent' => translate('Percent')], $product->discount_type, ['class' => 'form-control']) !!}

{{ translate('Variations') }} {{ translate('Allow your customers to choose from options such as or sizes on your store') }}

{!! Form::select('choice_attributes[]', $attributes, json_decode($product->attributes, true), ['style' => 'width: 100%;', 'multiple' => 'multiple', 'class' => 'form-control select2', 'id' => 'choice_attributes']) !!}
{{ translate('Choose the attributes of this product and then input values of each attribute') }}
@foreach (json_decode($product->choice_options) as $key => $choice_option)
{!! Form::hidden('choice_no[]', $choice_option->attribute_id) !!} @php $attr_title = \App\Attribute::with([ 'attribute_translations' => function ($tr) { $tr->where('lang', App::getLocale()); }, ])->find($choice_option->attribute_id); @endphp {!! Form::text('choice[]', getTranslation($attr_title, 'attribute_translations', 'title'), ['disabled' => 'disabled', 'class' => 'form-control', 'placeholder' => translate('Choice title')]) !!}
@php $attributes_options_arr = \App\AttributOption::select('id', 'title') ->with([ 'attribut_option_translations' => function ($tr) { $tr->where('lang', App::getLocale()); }, ]) ->get() ->toArray(); $this->choices_options = []; $attributes_collection = collect($attributes_options_arr); $attributes_collection = $attributes_collection->map(function ($item, $key) { $this->choices_options[$item['id']] = sizeof($item['attribut_option_translations']) > 0 ? $item['attribut_option_translations'][0]['title'] : $item['title']; return $this->choices_options; }); $selected_choices_options = $this->choices_options; @endphp
{!! Form::select('choice_options_' . $choice_option->attribute_id . '[]', $selected_choices_options, $choice_option->values, ['style' => 'width:100%;', 'onchange' => 'update_sku()', 'multiple' => 'multiple', 'class' => 'form-control select2']) !!}
@endforeach

{{ translate('Specs') }} {{-- {{ translate('Allow your customers to choose from options such as or sizes on your store') }} --}}

{{ translate('Show the product features in a simplified way to your customer, for example (length: 10 cm - width: 10 cm)') }}
{{ translate('Add spec') }}

@if (Session::get('serialized_specs_edit_array')) @foreach (Session::get('serialized_specs_edit_array') as $key => $value)
{!! Form::text('serialized_specs[key][]', $key, ['class' => 'form-control', 'placeholder' => translate('Spec key')]) !!}
{!! Form::text('serialized_specs[value][]', $value, ['class' => 'form-control', 'placeholder' => translate('Spec value')]) !!}
@endforeach @else @if ($product->serialized_specs) @forelse (json_decode($product->serialized_specs) as $key => $value)
{!! Form::text('serialized_specs[key][]', $key, ['class' => 'form-control', 'placeholder' => translate('Spec key')]) !!}
{!! Form::text('serialized_specs[value][]', $value, ['class' => 'form-control', 'placeholder' => translate('Spec value')]) !!}
@empty @endforelse @endif @endif
@if (Session::get('tenant_subscribtion_data')['meta_data']['belongs_to_subscribtion'] == true && Session::get('tenant_controle_modules')['meta_data'] == 1)

{{ translate('Meta') }} {{ translate('SEO results control what you see when this product is displayed in a search engine') }}

{!! Form::text('meta_title', getTranslation($product, 'product_translations', 'meta_title'), ['class' => 'form-control', 'placeholder' => translate('Meta title')]) !!}
@error('meta_title')
{{ $message }}
@enderror
{!! Form::textarea('meta_description', getTranslation($product, 'product_translations', 'meta_description'), ['rows' => 4, 'class' => 'form-control', 'placeholder' => translate('Meta description')]) !!}
@error('meta_description')
{{ $message }}
@enderror
@error('meta_image')
{{ $message }}
@enderror
@endif
{!! Form::Close() !!}

{{ translate('Product attaches') }} *

@endsection @section('modal') @endsection @section('script') @endsection