
<?php $id = $id ?? null;?>
@if(isset($id))
    {{ Form::model($data, ['route' => ['subcategory.update', $id], 'method' => 'patch' ]) }}
@else
    {{ Form::open(['route' => ['subcategory.store'], 'method' => 'post','data-toggle'=>"validator"]) }}
    {!! Form::hidden('store_detail_id', auth()->user()->store_detail_id) !!}
    {!! Form::hidden('storeowner_id', auth()->user()->id) !!}
@endif
<div class="modal-dialog modal-dialog-centered" role="subcategory">
    <div class="modal-content ">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">{{$pageTitle}}</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        <div class="modal-body">
            <div class="row">
                <div class="form-group col-md-12">
                    {{ Form::label('category_id', __('message.select_name',[ 'select' => __('message.category') ]),[ 'class' => 'form-control-label' ]) }}
                    {{ Form::select('category_id',isset($id) ? [ $data->id => $data->category->name ] : [], old('category_id'), [
                        'class' => 'form-control select2js  category','required',
                        'data-placeholder' => __('message.select_name',[ 'select' => __('message.category') ]),
                        'data-ajax--url' => route('ajax-list', ['type' => 'category-list']),
                    ]) }}
                     <span class="text-danger" id = "ajax_form_validation_category_id"></span>
                </div>
                <div class="col-md-12 form-group">
                    {{ Form::label('name',__('message.name').' <span class="text-danger">*</span>', ['class' => 'form-control-label'],false) }}
                    {{ Form::text('name', null, [ 'placeholder' => __('message.name') ,'class' => 'form-control' ,'required']) }}
                    <span class="text-danger" id = "ajax_form_validation_name"></span>
                 </div>
                 <div class="form-group col-md-12">
                    {{ Form::label('status',__('message.status'),['class'=>'form-control-label']) }}
                    {{ Form::select('status',[ '1' => __('message.enable'), '0' => __('message.disable') ], old('status'), [ 'class' =>'form-control select2js']) }}
                </div>
            </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-md btn-secondary" data-dismiss="modal">{{ __('message.close') }}</button>
                    <button type="submit" class="btn btn-md btn-primary"id="btn_submit" data-form="ajax-submite-jquery-validation" >{{ isset($id) ?  __('message.update') : __('message.save') }}</button>
                </div>
        </div>
        {{ Form::close() }}
    </div>
</div>
<script>
    (function ($) {
        $(document).ready(function () {
            $(".select2js").select2({
                width: "100%",
            });
        });
    })(jQuery);
</script>

