Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb 拉雷维尔,蒙戈,@foreach逻辑视图_Mongodb_Laravel_Foreach - Fatal编程技术网

Mongodb 拉雷维尔,蒙戈,@foreach逻辑视图

Mongodb 拉雷维尔,蒙戈,@foreach逻辑视图,mongodb,laravel,foreach,Mongodb,Laravel,Foreach,我有拉威尔与Mongodb和内部收集文件这样 }, "et_score": null, "starting_time": "13:00:00", "competition": { "active": true, "id": NumberInt("46"), "name": "Liga 1" }, "awayTeam": {

我有拉威尔与Mongodb和内部收集文件这样

},
        "et_score": null,
        "starting_time": "13:00:00",
        "competition": {
            "active": true,
            "id": NumberInt("46"),
            "name": "Liga 1"
        },
        "awayTeam": {
            "venue_id": NumberInt("2454"),
            "name": "Team away -> Liga1",
            "coach_id": NumberInt("140772"),
            "twitter": ""
        },
        "homeTeam": {
            "venue_id": NumberInt("0"),
            "name": "Team home -> Liga1",

        },
        "home_score": NumberInt("1"),
        "starting_date": "2016-12-24",
        "away_score": NumberInt("1")
    }
})

我的刀锋有这个

....
   @foreach($data_user as $league)

        <table class='table table-striped table-bordered table-condensed'>

         <thead><tr><th>{{$league{"competition.name"} }}</th></tr></thead>
            @endforeach

        <tbody>
            <tr>
                @foreach($data_user as $match)


                    <th>{{$match{"starting_date"} }}</th>
                    <th>{{$match{"starting_time"} }}</th>
                    <th>{{$match{"status"} }}</th>
                    <th>{{$match{"homeTeam.name"} }}</th>
                    <th>{{$match{"home_score"} }} : {{$match{"away_score"} }} </th>
                    <th>{{$match{"awayTeam.name"} }}</th>
            </tr>
            @endforeach
        </tbody>
        </table>
.....
。。。。
@foreach($data\u用户为$league)
{{$league{“competition.name”}}}
@endforeach
@foreach($data\U user as$match)
{{$match{“开始日期”}}
{{$match{“开始时间”}}
{{$match{“status”}}}
{{$match{“homeTeam.name”}}
{{$match{“主场得分”}}}:{{$match{“客场得分”}}
{{$match{“awayTeam.name”}}
@endforeach
.....
这张打印出来的表格和这张一样

正如你们所看到的,我把所有的球队都放在一张“卢埃加表”中,我会把球队分配到“主场->联赛”中,然后转到联赛1,而“主场->超级联赛”应该在超级联赛中,等等


我知道我在@foreach中缺少了一些逻辑,但我没有足够的经验来修复这样的问题,谢谢你,我不太明白你到底想做什么,但是从我看到的情况来看,他们错误地打开或关闭了你的foreach,除了模型使用不当之外,还生成了糟糕的html

回顾以下内容

@foreach($data_user as $league)
<table class='table table-striped table-bordered table-condensed'>
    <thead>
        <tr>
            <th>{{$league->competition->name }}</th>
        </tr>
    </thead>
    <tbody>
        @foreach($data_user as $match)
        <tr>
            <th>{{$match->starting_date }}</th>
            <th>{{$match->starting_time }}</th>
            <th>{{$match->status }}</th>
            <th>{{$match->homeTeam.name }}</th>
            <th>{{$match->home_score }} : {{ $match->away_score }} </th>
            <th>{{$match->awayTeam.name }}</th>
        </tr>
        @endforeach
    </tbody>
</table>
@endforeach
@foreach($data\u用户为$league)
{{$league->competition->name}
@foreach($data\U user as$match)
{{$match->开始日期}
{{$match->开始时间}
{{$match->status}
{{$match->homeTeam.name}
{{$match->home{u score}}:{{{$match->way{u score}
{{$match->awayTeam.name}
@endforeach
@endforeach

如果您看到模型和控制器,可能需要更多帮助

型号:

<?php

namespace App\Models;

use Moloquent;

class PrimaryModels extends Moloquent
{
    protected $collection = 'football.live';
}

但如果我这样做,山姆会怀疑所有球队都在所有联赛中

@foreach($data_user as $league)
    <table class='table table-striped table-bordered table-condensed'>
        <thead>
        <tr>
            <th>{{$league{"competition.name"} }}</th>
        </tr>
        </thead>
        <tbody>
        @foreach($data_user as $match)
            <tr>
                <th>{{$match->starting_date }}</th>
                <th>{{$match->starting_time }}</th>
                <th>{{$match->status }}</th>
                <th>{{$match{"homeTeam.name"} }}</th>
                <th>{{$match->home_score }} : {{ $match->away_score }} </th>
                <th>{{$match{"awayTeam.name"} }}</th>
            </tr>
        @endforeach
        </tbody>
    </table>
@endforeach
@foreach($data\u用户为$league)
{{$league{“competition.name”}}}
@foreach($data\U user as$match)
{{$match->开始日期}
{{$match->开始时间}
{{$match->status}
{{$match{“homeTeam.name”}}
{{$match->home{u score}}:{{{$match->way{u score}
{{$match{“awayTeam.name”}}
@endforeach
@endforeach

Hi Manuel,您的建议有误:尝试在第4行获取非对象的属性该信息是模型、集合或数组的结果?检查这一点,或者添加更多信息来帮助您,但请记住,您关闭foreach错误,并在f1da8afe98aba2781763f1e975725bb2aaa771cf.php第5行中生成带有ErrorErrorErrorException的HTML:尝试获取非对象的属性以获取非对象的属性(View:/Volumes/WEB/test/CRUD-Laravel-5.3-with-MongoDB/resources/views/myhome.blade.php)显示您的代码返回的信息,是雄辩的结果、集合、数组吗?很抱歉,我不理解您的问题,您的确切意思是什么?
@foreach($data_user as $league)
    <table class='table table-striped table-bordered table-condensed'>
        <thead>
        <tr>
            <th>{{$league{"competition.name"} }}</th>
        </tr>
        </thead>
        <tbody>
        @foreach($data_user as $match)
            <tr>
                <th>{{$match->starting_date }}</th>
                <th>{{$match->starting_time }}</th>
                <th>{{$match->status }}</th>
                <th>{{$match{"homeTeam.name"} }}</th>
                <th>{{$match->home_score }} : {{ $match->away_score }} </th>
                <th>{{$match{"awayTeam.name"} }}</th>
            </tr>
        @endforeach
        </tbody>
    </table>
@endforeach