我有城市表,它有 7 个城市我有一个查看页面来显示这些城市,每页有 10 个城市
控制器:
$cities = City::orderBy('id', 'desc')->paginate(10);
return view('cities.home', compact('cities'));
看法:
<div class="table-responsive panel panel-sky">
<table class="table table-striped table-hover">
<tr>
<th>#</th>
<th>Name</th>
<th>Created At</th>
<th>Action</th>
</tr>
@foreach($cities as $city)
<tr id="product{{$city->id}}">
<td>{{$city->id}}</td>
<td>{{$city->name}}</td>
<td>{{ $city->created_at }}</td>
<td>
<a href="{{ url('product/' . $city->id . '/edit') }}"><i class="glyphicon glyphicon-edit action-icon"></i></a>
<a type="button" class="pointer" data-toggle="modal" data-target="#deleteModal" data-type="btn-danger" data-action="delete-product" data-id="{{ $city->id }}" data-msg="Are you sure you want to delete this city?" data-title="Confirm Deletion">
<span class='glyphicon glyphicon-remove action-icon'></span>
</a>
</td>
</tr>
@endforeach
</table>
<div>
<div class="col-md-12"><?php echo $cities->render(); ?> </div>
但问题是分页渲染显示为第 1 页,此问题发生在 laravel5.3 中,在 laravel5.2 中未发现