zizohassan / adssystem

Ads system with mutli language admin panel
MIT License
6 stars 6 forks source link

error in add product view #5

Open mRamadan0101 opened 6 years ago

mRamadan0101 commented 6 years ago

when i try to add new product and select user nothing display this script file :

<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<script>
    $(".ajaxSelect").select2({
        ajax: {
            url: "{{ concatenateLangToUrl('admin/getUser') }}",
            dataType: 'json',
            delay: 250,
            data: function (params) {
                return {
                    q: params.term, // search term
                    page: params.page
                };
            },
            processResults: function (data, params) {
                // parse the results into the format expected by Select2
                // since we are using custom formatting functions we do not need to
                // alter the remote JSON data, except to indicate that infinite
                // scrolling can be used
                params.page = params.page || 1;
                return {
                    results: data.items,
                    pagination: {
                        more: (params.page * 30) < data.total_count
                    }
                };
            },
            cache: true
        },
        escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
        minimumInputLength: 1,
        templateResult: formatRepo, // omitted for brevity, see the source of this page
        templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
    });
    function formatRepo (repo) {
        if (repo.loading) return repo.name;
        var markup = repo.name;
        return markup;
    }
    function formatRepoSelection (repo) {
        return repo.name;
    }
</script>

and this view edit file

@extends(layoutExtend())

@section('title')
    {{ trans('product.product') }} {{  isset($item) ? trans('home.edit')  : trans('home.add')  }}
@endsection

@section('style')

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />

@endsection

@section('content')
    @component(layoutForm() , ['title' => trans('product.product') , 'model' => 'product' , 'action' => isset($item) ? trans('home.edit')  : trans('home.add')  ])
         @include(layoutMessage())
        <form action="{{ concatenateLangToUrl('admin/product/item') }}{{ isset($item) ? '/'.$item->id : '' }}" method="post" enctype="multipart/form-data">
            {{ csrf_field() }}

        <div class="form-group">
            <label for="name">{{ trans("product.name")}}</label>
<input type="text" name="name" value="{{ isset($item) ? $item->name : null }}" class="form-control">

        </div>

        <div class="form-group">
            <label for="des">{{ trans("product.des")}}</label>
<textarea type="text" name="des" class="form-control" rows="8">{{ isset($item) ? $item->des : null }}</textarea>

        </div>

           <div class="form-group">
            <label>{{ adminTrans('product' , 'status')}}</label>

            @php $status = isset($item) ? $item->status : null @endphp

            {!! Form::select('status' , productStatus() , $status) !!}
        </div>

<div class="form-group">
            <label for="price">{{ trans("product.price")}}</label>
<input type="text" name="price" value="{{ isset($item) ? $item->price : null }}" class="form-control">

        </div>
        <div class="form-group">
            <label for="lat">{{ trans("product.lat")}}</label>
<input type="text" name="lat" value="{{ isset($item) ? $item->lat : null }}" class="form-control">

        </div>

        <div class="form-group">
            <label for="lang">{{ trans("product.lang")}}</label>
<input type="text" name="lang" value="{{ isset($item) ? $item->lang : null }}" class="form-control">

        </div>
                <div class="form-group">
            <label for="phone">{{ trans("product.phone")}}</label>
<input type="text" name="phone" value="{{ isset($item) ? $item->phone : null }}" class="form-control">

        </div>

<div class="form-group">
                <div class="form-line">
                    <label for="">{{ trans("product.image") }}</label>
                    @if(isset($item) && $item->image != '')
                        <br>
                        <img src="{{ url('/'.env('SMALL_IMAGE_PATH').'/'.$item->image) }}" class=" thumbnail" alt="">
                        <br>
                    @endif    
                    <input type="file" name="image" class="" {{ !isset($item) ? "required='required'" : '' }}>
                </div>
</div>

   <div class="form-group">
            <label>{{ adminTrans('product' , 'country_id')}}</label>

            @php $countryName = isset($item) ? $item->country_id : null @endphp

            {!! Form::select('country_id' , $data['data']['country'] , $countryName) !!}
        </div>

   <div class="form-group">
            <label>{{ adminTrans('product' , 'state_id')}}</label>

            @php $stateName = isset($item) ? $item->state_id : null @endphp

            {!! Form::select('state_id' , $data['data']['state'] , $stateName) !!}
        </div>

        <div class="form-group">
            <label for="">{{ adminTrans('product' , 'user_id') }}</label>
            @if(!isset($item))
                {!! Form::select('user_id' , [] , null , ['class' => 'form-control ajaxSelect'] ) !!}
            @else
               <a href="{{ concatenateLangToUrl('admin/user/item/'.$data['data']['user_id']->id) }}"> {{ $data['data']['user_id']->name  }}</a>
            @endif
</div>

           <div class="form-group">
            <label>{{ adminTrans('product' , 'cat_id')}}</label>

            @php $catName = isset($item) ? $item->cat_id : null @endphp

            {!! Form::select('cat_id' , $data['data']['cat_id'] , $catName) !!}
        </div>

            <div class="form-group">
                <button type="submit" name="submit" class="btn btn-default" >
                    <i class="material-icons">check_circle</i>
                    {{ trans('home.save') }}  {{ trans('product.product') }}
                </button>
            </div>
        </form>
    @endcomponent
@endsection

@section('script')
    @include('admin.product.scripts.script')

@endsection

im using laraflat 2.0.0 wamp server

mRamadan0101 commented 6 years ago

parameter q

q | admin
-- | --

and this error msg response when i inspect element SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data