mardi 22 mars 2022

foreach with config data file laravel

I´m traying create rows check if in my product array have any product in config file. If in my array product have any value that coincide with my config file, in this column put a ex image.

in my config file y have this:

return [
    'productos' => [
        "DFDAP20" => [
            'label' => 'DFDAP20',
            'text'  => 'DEPURADOR FLUJO DIRECTO AQUALUXE PREMIUM 2.0'
        ],
        "DDP20" => [
            'label' => 'DDP20',
            'text'  => 'DESINCRUSTADOR DCALUXE PRO 2.0'
        ],
        /* RENOMBRADO A DIA 02/12/2020 POR EQUIPO DE GENERADOR DE HIDROGNEO
        "DESDPU" => [
            'label' => 'DESDPU',
            'text'  => 'DESINFECCIÓN DE DEPURADORA'
        ],*/
        "EGENO" => [
            'label' => '1110',
            'text'  => 'EQUIPO GENERADOR DE HIDRÓGENO'
        ],
        "FAOS" => [
            'label' => 'FAOS',
            'text'  => 'FUENTE DE AGUA OSMOTIZADA'
        ],
        "G4V" => [
            'label' => 'G4V',
            'text'  => 'GRIFO DE CUATRO VÍAS'
        ],
        "SLOXIWATER" => [
            'label' => '1133',
            'text'  => 'SISTEMA DE LIMPIEZA OXI WATER'
        ],
        "JUEGOFILTROS" => [
            'label' => 'JUEGOFILTROS',
            'text'  => 'JUEGO DE FILTROS'
        ]
    ]
];

in my product array i have this:

Array
(
    [0] => Array
        (
            [codigo] => 41
            [ref] => 1110
            [nombre] => EQUIPO GENERADOR DE HIDROGENO HYDROGEN 333 TECH
            [precio] => 999.99
            [cantidad] => 1
            [id_precontrato] => 14900
        )

    [1] => Array
        (
            [codigo] => 129
            [ref] => 674
            [nombre] => PIZZA  PAN NW407 DORADO
            [precio] => 39.48
            [cantidad] => 1
            [id_precontrato] => 14900
        )

    [2] => Array
        (
            [codigo] => 291
            [ref] => 956
            [nombre] => COLECCIÓN COCINA INTERNACIONAL, ALTA GASTRONOMÍA INTERNACIONAL, COCINA EQUILIBRADA Y SALUDABLE. HD - 3D, 2 TOMOS+1DVD (GD)
            [precio] => 140.09
            [cantidad] => 1
            [id_precontrato] => 14900
        )

)

and in my blade i´m doing a foreach that check if any value it´s in array:

@foreach(config('instalacion')['productos'] as $key => $value)
          <div class="cajas2" style="height: 25px; border:1px solid black; position: relative;">
            @if(in_array($value["text"], $productos))
              <img src="" style="width: 16px; position: absolute; left: 40%; top: 50%; transform: translateY(-50%); -webkit-transform: translateY(-50%);">
            
            @else
              @php
                echo "eee";
                print_r($productos);
              @endphp
            @endif
          </div>
        @endforeach

but always get in else...

I don´t know that i´m doing wrong, but i can´t solve this problem.

Thanks for readme and sorry for my english



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire