@foreach- Error

alexm posted 2 weeks ago

Hello everyone ... I have this problem, it is complicated to explain so I will try to summarize the easiest to help me,

First in my db I have a field in which I concatenate several numbers, the db adp:

ID - Id_fijacion - nr

1  - 1           -  4|5|5|7|....|n-1|n

What I am trying to do is to join 3 db, but dividing the chain concatnada(nr: 4|5|5|7|....|n-1|n)

This will do it already.


    $Metrop  = DB::table('fijacion')->where('tipo','Metro')->join('adp', '', '=', "adp.id_fijacion")->get();

    foreach($Metrop as $Metro){
        $array = explode("|", $Metro->nr);
        $Metro = DB::table('fijacion')->where('tipo','Metro')->join('adp', '', '=', "adp.id_fijacion")->get();
        $MetroA[] = DB::table('users')
                  ->where('categoria', '<=', 3)
                  ->join('puntos', 'users.numero', '=', "")
                  ->orderby('categoria', 'asc')
                  ->orderby('total', 'asc')

return view('UJOBBPanel.Designaciones.index',compact('Metro', 'MetroA'));


@foreach($Metro as $Metro)

<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($MetroA as $MetroA)
<option value="{{$MetroA->numero}}">{{$MetroA->nombre}}. {{$MetroA->apellido}}</option>

And I had the following error:

Property [numero] does not exist on this collection instance.

And this with the 3 variables, can someone give me a hand?

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us