首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Laravel脚本中遇到的非数字值

在Laravel脚本中遇到的非数字值
EN

Stack Overflow用户
提问于 2018-12-31 16:02:40
回答 1查看 4.1K关注 0票数 0

在页面上的Laravel脚本中,出现了以下错误:

“遇到的非数字值(View: /home/grammer/public_html/test/core/resources/views/admin/apiServices.blade.php)”)

这条线

我的页码:

代码语言:javascript
运行
复制
@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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-31 18:31:51

只需添加以下内容:

代码语言:javascript
运行
复制
<td>{{ (int) $key + 1 }}</td>

添加以下内容:

代码语言:javascript
运行
复制
$key = (int) $key; // GET NUMBER FROM VARIABLE
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53989306

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档