mardi 31 mars 2020

How to fetch all the data from a table minus the last element in laravel

I currently have a table where I need to review the details of an ATM but I do not need to view the last registered item

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]);
    }

the variable $respuestas is in charge of bringing the data I need, but currently I bring the last element linked to the cashier and I need to do the opposite.

I need you to only show me the data linked to the ATM, all except the last one entered.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire