@extends('admin.main') @php use App\Helpers\Form as FormTemplate; use App\Helpers\Template; $formInputAttr = config('zvn.template.form_input'); $formLabelAttr = config('zvn.template.form_label'); $formCkeditor = config('zvn.template.form_ckeditor'); $statusValue = ['default' => 'Select status', 'active' => config('zvn.template.status.active.name'), 'inactive' => config('zvn.template.status.inactive.name')]; $srcThumb = asset('images/product'); $inputHiddenID = Form::hidden('id', @$item['id']); $elements = [ [ 'label' => Form::label('name', 'Name', $formLabelAttr), 'element' => Form::text('name', @$item['name'], $formInputAttr), ], [ 'label' => Form::label('content', 'Content', $formLabelAttr), 'element' => Form::textArea('content', @$item['content'], $formCkeditor), ], [ 'label' => Form::label('status', 'Status', $formLabelAttr), 'element' => Form::select('status', $statusValue, @$item['status'], $formInputAttr), ], [ 'label' => Form::label('category_id', 'Category', $formLabelAttr), 'element' => Form::select('category_id', $itemsCategory, @$item['category_id'], $formInputAttr), ], [ 'label' => Form::label('thumb', 'Thumb', $formLabelAttr), 'element' => Form::file('thumb', $formInputAttr), 'thumb' => !empty(@$item['id']) ? Template::showItemThumb($controllerName, @$item['thumb'], @$item['name']) : null, 'type' => 'dropzone', ], [ 'element' => $inputHiddenID . Form::submit('Save', ['class' => 'btn btn-success']), 'type' => 'btn-submit', ], ]; $attributeElements = []; $itemsAttribute = [ [ "id" => 2, "name" => "Slogan" ], [ "id" => 1, "name" => "Màu sắc" ] ]; foreach ($itemsAttribute as $key => $value) { $id = $value['id']; $func = function ($funcValue) use ($value) { if ($funcValue['attribute_id'] == $value['id']) { return $funcValue['value']; } }; $productAttributeValues = []; if ($itemsProductAttribute) { $productAttributeValues = array_filter(array_map($func, $itemsProductAttribute)); } $attributeItem = [ 'label' => Form::label($id, $value['name'] ?? '', $formLabelAttr), 'element' => Form::text($id, implode(',', $productAttributeValues) ?? null, array_merge($formInputAttr, ['data-role' => 'tagsinput'])), ]; $attributeElements[] = $attributeItem ?? null; } $attributeElements[] = [ 'element' => $inputHiddenID . Form::submit('Save', ['class' => 'btn btn-success']), 'type' => 'btn-submit', ]; $itemsAttributePrice = [ [ "id" => 3, "name" => "Màu" ] ]; $xhtml = ''; $sortableOrdering = []; $ordering = 0; $defaultDeleteButton = Template::showItemDeleteButton($controllerName, 0); foreach ($itemsProductAttribute as $key => $valuePA) { if ($valuePA['attribute_id'] == 3) { $itemValue = $valuePA['value'] ?? ''; $itemValuePrice = $valuePA['value_price'] ?? 0; $itemId = $valuePA['id'] ?? 0; $ordering++; $sortableOrdering[] = $ordering; $itemDefault = (int)$valuePA['default']; $itemDefaultCheck = ($itemDefault) ? 'checked="true"': ''; $deleteButton = Template::showItemDeleteButton($controllerName, $itemId); $xhtml .= sprintf('
  • Default %s
  • ', $ordering, $itemValue, $itemValuePrice, $itemId, $itemDefault, $itemDefault, $itemDefaultCheck, $deleteButton); } } $sortableOrderingString = implode(',', $sortableOrdering); $inputHiddenSortable = Form::hidden('sortable-9', $sortableOrderingString, ['id' => 'sortable-9']); $value = $itemsAttributePrice[0]; $attributePriceItem = [ 'label' => Form::label($id, $value['name'] ?? '', $formLabelAttr), 'element' => '', ]; $attributePriceElements[] = $attributePriceItem ?? null; $attributePriceElements[] = [ 'element' => $inputHiddenID . $inputHiddenSortable . Form::button('Add', ['class' => 'btn btn-primary', 'id' => 'btn_add_price']) . Form::submit('Save', ['class' => 'btn btn-success']), 'type' => 'btn-submit', ]; @endphp @section('content') @include ('admin.templates.page_header', ['pageIndex' => false]) @include ('admin.templates.error')
    @include('admin.templates.x_title', ['title' => 'Thông tin cơ bản của sản phẩm'])
    {{ Form::open([ 'method' => 'POST', 'url' => route("$controllerName/save"), 'accept-charset' => 'UTF-8', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal form-label-left', 'id' => 'main-form', ]) }} {!! FormTemplate::show($elements) !!} {{ Form::close() }}
    @include('admin.templates.x_title', ['title' => 'Thuộc tính sản phẩm'])
    {{ Form::open([ 'onkeydown' => "return event.key != 'Enter';", 'method' => 'POST', 'url' => route("$controllerName/save-attribute"), 'accept-charset' => 'UTF-8', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal form-label-left', 'id' => 'attribute-form', ]) }} {!! FormTemplate::show($attributeElements) !!} {{ Form::close() }}
    @include('admin.templates.x_title', ['title' => 'Giá sản phẩm'])
    {{ Form::open([ 'onkeydown' => "return event.key != 'Enter';", 'method' => 'POST', 'url' => route("$controllerName/save-attribute-price"), 'accept-charset' => 'UTF-8', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal form-label-left', 'id' => 'attribute-form', ]) }} {!! FormTemplate::show($attributePriceElements) !!} {{ Form::close() }}
    @endsection @push('custom-script') @endpush