mardi 31 mars 2020

how to select all the data corresponding to an id and display it in a table in laravel

I am currently developing an ATM application which shows certain work done, these elements are associated with a user id, what I need to show in my table is all the elements associated with the id of my ATM, as I am new to laravel I am not clear how to handle the query, Currently my DB fields are as follows

enter image description here

I need to show for example all the data associated with the usuario_id field that appears in the image.

the function that I am currently using and that brings me the data is the following where $respuestas is my variable to show them in my view.

function show($id) {
        $atm = Atm2::find($id);
        $respuestas = FormularioRespuesta2::whereAtmId($atm->id)->orderBy('id', 'asc')->get();
        $formulario = Formulario2::first();
        $respuesta = FormularioRespuesta2::whereAtmId($atm->id)->orderBy('id', 'desc')->first();
        $respuestas = $respuestas->where('atm_id', '=', $atm->id);
        return view('Administrador::atms2-show')->with(['atm' => $atm, 'formulario' => $formulario, 'respuesta' => $respuesta, 'respuestas' => $respuestas]);
    }

currently this function only brings me the last record and not the entire list items that the cashier has made.

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/39ySIuW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire