我有一個問題,我在數據庫請求一些數據,其中一人被連接領域已形成這樣的:Laravel爆炸並加入
1 | 2 | 3 | ... | n-1 | n,
的問題是,每一個數值我要加入另一張桌子。
$Metro = DB::table('fijacion')->where('tipo','Metro')->join('adp', 'fijacion.id', '=', "adp.id_fijacion")->get();
是發生在我的解決方案是,鏈鴻溝這麼
foreach($Metro as $Metro){
$array = explode("|", $Metro->nr);
$MetroXI = DB::table('users')
->select('numero','nombre','apellido')
->whereIn('numero',$array)
->where('categoria', 1)
->join('puntos', 'users.numero', '=', "puntos.nr")
->orderBy('puntos.Total', 'asc')
->get();
}
這打破了連鎖,但它只能說明我的結果
我知道這是令人困惑的理解,但如果有人可以指導我如何正確使用這種方法,或者有些想法會很感謝
$ Metro:
[{"id":1,"semana":32,"fecha":"2017-08-11","dia":"Viernes","tipo":"Metro","categoria":null,"hora":"20:30 ","cancha":"CAPITOL ","partido":"CAPITOL \u2013 TABAR\u00c9 ","nr_1":null,"arbitro_1":null,"nr_2":null,"arbitro_2":null,"nr_3":null,"arbitro_3":null,"aux":1,"updated_at":"2017-08-07 12:04:04","created_at":"2017-08-07 12:03:57","id_fijacion":1,"nr":"7|22|29|31|32|40|53|59|66|67|68|77|5|12|13|17|18|20|24|27|28|33|35|37|44|46|50|52|61|64|65|75|23|25|26|39|47|48|51|58|69|74|80|82|83|86|93|96|104|109|117|120","designado":0},{"id":2,"semana":32,"fecha":"2017-08-11","dia":"Viernes","tipo":"Metro","categoria":null,"hora":"20:30 ","cancha":"MIRAMAR ","partido":"MIRAMAR \u2013 COL\u00d3N ","nr_1":null,"arbitro_1":null,"nr_2":null,"arbitro_2":null,"nr_3":null,"arbitro_3":null,"aux":1,"updated_at":"2017-08-07 12:04:04","created_at":"2017-08-07 12:03:57","id_fijacion":2,"nr":"7|22|29|31|32|40|53|59|66|67|68|77|5|12|13|17|18|20|24|27|28|33|35|37|44|46|50|52|61|64|65|75|23|25|26|39|47|48|51|58|69|74","designado":0},{"id":3,"semana":32,"fecha":"2017-08-11","dia":"Viernes","tipo":"Metro","categoria":null,"hora":"20:30 ","cancha":"SAYAGO ","partido":"ATENAS \u2013 AURIBLANCO ","nr_1":null,"arbitro_1":null,"nr_2":null,"arbitro_2":null,"nr_3":null,"arbitro_3":null,"aux":1,"updated_at":"2017-08-07 12:04:04","created_at":"2017-08-07 12:03:57","id_fijacion":3,"nr":"28|33|35|37|44|46|50|52|61|64|65|75|23|25|26|39|47|48|51|58|69|74|80|82|83|86|93|96|104|109|117|120","designado":0},{"id":4,"semana":32,"fecha":"2017-08-11","dia":"Viernes","tipo":"Metro","categoria":null,"hora":"20:30 ","cancha":"CORD\u00d3N \u2013 SIN P\u00daBLICO VISITANTE ","partido":"CORD\u00d3N \u2013 25 DE AGOSTO ","nr_1":null,"arbitro_1":null,"nr_2":null,"arbitro_2":null,"nr_3":null,"arbitro_3":null,"aux":1,"updated_at":"2017-08-07 12:04:05","created_at":"2017-08-07 12:03:57","id_fijacion":4,"nr":"7|22|29|31|32|40|53|59|66|67|68|77|5|12|13|17|18|20|35|37|44|46|50|52|61|64|65|75|23|25|26|39|47|48|51|58|69|74|80|82|83|86|93|96|104|109|117|120","designado":0},{"id":5,"semana":32,"fecha":"2017-08-11","dia":"Viernes","tipo":"Metro","categoria":null,"hora":"20:30 ","cancha":"STOCKOLMO ","partido":"STOCKOLMO \u2013 UNI\u00d3N ATL\u00c9TICA ","nr_1":null,"arbitro_1":null,"nr_2":null,"arbitro_2":null,"nr_3":null,"arbitro_3":null,"aux":1,"updated_at":"2017-08-07 12:04:05","created_at":"2017-08-07 12:03:57","id_fijacion":5,"nr":"7|22|29|31|32|40|53|59|66|67|68|77|5|12|13|17|18|20|24|27|28|33|35|37|44|46|50|52|61|64|65|75|23|25|26|39|47|83|86|93|96|104|109|117|120","designado":0}]
在NR值是我必須參加它
由於@yoeunes loger avanasa,但現在我認爲我有錯誤。
哪,我意識到我並沒有涉及$地鐵$ MetroXI []
這裏是我的.blade 參數這是我的看法:
@foreach($Metro as $Metro)
<tr>
<th>{{$Metro->dia}}</th>
<th>{{$Metro->fecha}}</th>
<th>{{$Metro->categoria}}</th>
<th>{{$Metro->hora}}</th>
<th>{{$Metro->cancha}}</th>
<th>{{$Metro->partido}}</th>
<th>@php$array = explode("|", $Metro->nr);$pepe = count($array);@endphp{{ $pepe }}</th>
<select class="form-control" name="select1" id="arbitro_1">
<option selected="true" disabled="disabled">Selecione 1º Arbitro</option>
<option disabled="disabled">---Internacional---</option>
@foreach($MetroXI as $MetroXI)
<option value="{{$MetroXI->numero}}">{{$MetroXI->nombre}}. {{$MetroXI->apellido}}</option>
@endforeach
</select>
@endforeach
你給我的錯誤是:
此集合實例中不存在屬性[nr]。
併發生3個變量。
你期望得到什麼結果?舉一些例子 – Laerte
你正在循環變量'foreach($ Metro爲$ Metro)' – yoeunes