dpq59734 2018-06-06 07:52
浏览 109

未定义属性:Illuminate \ Pagination \ LengthAwarePaginator :: $ id(查看:C:\ xampp \ htdocs \ medipro55 esources \ views \ admin \ division \ index.blade.php)

i am try to update request data with jquery form i get only that error i found any solve but not. That is my view page. Edit button

<button type="button" class="btn btn-pill btn-outline-primary btn-sm open_model" data-toggle="modal" data-target="#editModal" data-id="{!! $d->id !!}"
                                                    data-description="{!! $d->description !!}"
                                                    data-sorting="{!! $d->sorting !!}">
                                            <i class="fa fa-pencil"></i> Edit
                                        </button>

(index.blade.php)

{!! Form::open(['url' => 'divisions/'.$divisions->id, 'method' => 'PUT', 'class' => 'form-horizontal']) !!}
<div class="form-group row">
    <label class="col-md-3 col-form-label" for="name">Division</label>
    <div class="col-md-9">
        <input type="text" id="description" name="description" value="{{old('description')}}" class="form-control" placeholder="Enter Division..">
        <input type="hidden" class="form-control" name="id" id="id">
        <span class="help-block"></span>
        @if ($errors->has('description'))
        <span class="text-danger">{{ $errors->first('description') }}</span>
        @endif
    </div>
</div>
<div class="form-group row">
    <label class="col-md-3 col-form-label" for="sort">Sort</label>
    <div class="col-md-9">
        <input type="text" id="sorting" name="sorting" value="{{old('sorting')}}" class="form-control" placeholder="Enter Sort..">
        <span class="help-block"></span>
        @if ($errors->has('sorting'))
        <span class="text-danger">{{ $errors->first('sorting') }}</span>
        @endif
    </div>
</div>
<div class="pull-right">
    <button type="submit" class="btn btn-pill btn-success btn-outline-success">
    Update</button>
    <button type="button" data-dismiss="modal" class="btn btn-pill btn-danger btn-outline-danger">
    Close</button>
</div>
{!! Form::close() !!}

that my jquery code for my edit popup model form

$( document ).ready(function() {
    $('#editModal').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget)
        var description = button.data('description')
        var sorting = button.data('sorting')
        var id = button.data('id')
        var modal = $(this)
        modal.find('.modal-body #description').val(description)
        modal.find('.modal-body #sorting').val(sorting)
        modal.find('.modal-body #id').val(id)
        // alert('id');
    });
});

DivisionController.php

public function index()
{
    $divisions = Division::paginate(10);
    return view('admin.division.index')->with('divisions', $divisions);
}
  • 写回答

1条回答 默认 最新

  • douwa1304 2018-06-06 09:27
    关注

    $divisions is a paginator object that serves a collection of division. Paginator doesn't have the $id parameter - the individual divisions have.

    You'll need to iterate through the paginator to get individual divisions and only then you'll be able to get their IDs, e.g.:

    @foreach ($divisions as $division)
      {{ $division->id }}
    @endforeach
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题