eloquent query does not bring me records when I make a select

1

I have the following query in eloquent that shows me the records

Usuario::with(['rutas'=> function($query){
        $query ->select('rutas.*','puntosDeVenta.id_puntodeventa','puntosDeVenta.codigo')
               ->join('puntosDeVenta','puntosDeVenta.id_puntodeventa','=','rutas.id_puntodeventa')
               ->join('subcadenas','subcadenas.id_subcadena','=','puntosDeVenta.id_subcadena')
               ->where('rutas.fecha','=','2018-08-20');

        }])->get();

what returns:

{
    "id_usuario": 2,
    "rut": "12345678-9",
    "nombre": "Administrador",
    "apellido": "Demo",
    "correo": "[email protected]",
    "acceso": "ADMINISTRADOR",
    "id_supervisor": 1,
    "api_token": "mIJoxWmPD7YmowaS7T2GRXWlxZn5bjkrff8wijELln9shLs8d0KcBcEUkyLF",
    "imagen": "defaultAdm.png",
    "estado": "DESCONECTADO",
    "rutas": [
        {
            "id_ruta": 1,
            "id_usuario": 2,
            "id_puntodeventa": 1,
            "id_empresa": 1,
            "usuario_validador": null,
            "estado": "PENDIENTE",
            "fecha": "2018-08-20",
            "lat": "",
            "long": "",
            "hora_validacion": null,
            "hora_checkout": null,
            "hora_sincronizacion": null,
            "fecha_validacion": null,
            "TIPO": "RUTA",
            "codigo": "CE001"
        }

which is correct, but when I change

select('rutas.*','puntosDeVenta.id_puntodeventa','puntosDeVenta.codigo')

for

select('rutas.id_ruta','puntosDeVenta.id_puntodeventa','puntosDeVenta.codigo')

gives me the empty 'route' field

 {
    "id_usuario": 2,
    "rut": "12345678-9",
    "nombre": "Administrador",
    "apellido": "Demo",
    "correo": "[email protected]",
    "acceso": "ADMINISTRADOR",
    "id_supervisor": 1,
    "api_token": "mIJoxWmPD7YmowaS7T2GRXWlxZn5bjkrff8wijELln9shLs8d0KcBcEUkyLF",
    "imagen": "defaultAdm.png",
    "estado": "DESCONECTADO",
    "rutas": []
}

To what is the way I solve it, I tried the query directly in mysql and it brings me the values

Thanks !!!

    
asked by WorseMzg 26.09.2018 в 17:11
source

0 answers