在页面上的Laravel脚本中,出现此错误:
“遇到非数字值(查看:/home/grammer/public_html/test/core/resources/views/admin/apiServices.blade.php)”
此行
<td>{{ $key+1 }}</td>
我的页面代码:
@extends('admin.layouts.master')
@section('page_icon', 'fa fa-suitcase')
@section('page_name', 'API Services')
@section('body')
<div class="row">
<div class="col-md-12">
<div class="tile">
<h3 class="tile-title">API Services List</h3>
<table class="table table-hover">
<thead>
<tr>
<th>Serial</th>
<th>Service ID</th>
<th>Name</th>
<th>Category</th>
<th>Price</th>
<th>Min</th>
<th>Max</th>
</tr>
</thead>
<tbody>
@foreach($items as $key => $item)
<tr>
<td>{{ $key+1 }}</td>
<td>{{ isset($item->service->id) ? $item->service->id : $item->service}}</td>
<td>{{ $item->name }}</td>
<td>{{ $item->category }}</td>
<td>{{ isset($item->rate) ? $item->rate : $item->price_per_k }} $</td>
<td>{{ $item->min }}</td>
<td>{{ $item->max }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endsection
答案 0 :(得分:0)
只需添加:
<td>{{ (int) $key + 1 }}</td>
或添加此内容:
$key = (int) $key; // GET NUMBER FROM VARIABLE