jeudi 19 mars 2020

Duplicate data in query with laravel 5.4

Currently I have two variables to call some processes, when editing the selectable points are duplicated to detail those processes

  $puntos = NormaPunto::select('id', 'clausula', 'descripcion', 'norma_id')
            ->whereIn('norma_id', $normas_id)
            ->where('visible_en_auditoria', true)
            ->orderBy('clausula', 'ASC')
        ->get();

    $puntos_precargar = NormaPunto::select('id', 'clausula')->whereIn('norma_id', $normas_id)
        ->whereNull('padre_id')->where('clausula', '!=', '')->whereNotNull('clausula')
        ->orderBy('clausula', 'ASC')
        ->where(function ($query) use ($lista) {
            $query->whereIn('id', $lista->puntosAuditorias()->pluck('punto_id'))
                ->orWhereHas('hijos', function ($has) use ($lista) {
                    $has->whereIn('id', $lista->puntosAuditorias()->pluck('punto_id'));
                });
        })->get();

this code generates the following view by duplicating the id and the clause

enter image description here

$puntos load the total points and $puntos_cargar brings me the marked fields



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire