Hi I found the solution, the problem was the groupBy('marca_auto.id_marca'), I was wrong, based on what grouping id_marca, so i need used productos.codigo_interno use and works perfect, I leave the solution if someone helps you
Change
->groupBy('marca_auto.id_marca')
To
->groupBy('productos.codigo_interno')
and move group tu down, the final code is
$productos = DB::table('productos as productos')
->leftJoin('marcas_modelos_autos as marca_auto', 'marca_auto.codigo_interno', '=', 'productos.codigo_interno')
->select('productos.id','productos.slug','productos.nombre','productos.precio')
->where('marca_auto.id_marca', '=', $id)
->orWhereNotExists(function($query)
{
$query->select(DB::raw(('*')))
->from('marcas_modelos_autos as marca_auto')
->whereRaw('marca_auto.codigo_interno = productos.codigo_interno');
})
->groupBy('productos.codigo_interno')
->get();
Regards!!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community