Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
Laravel Eloquent select where latest equal to value

I have two MySQL tables, the second table recorded the states of an attribute of the first table, I need to get all the records of the first table where the last state of the attribute is equal to value, how to do it with eloquent ?

here is my code that I need to add the condition to :

    //Materiels table1
    //Journal_etat_materiels table2

    function getMaterielForAff(Request $request)
    {
        $data = Materiel::join('Types', 'Materiels.type_id', '=', 'Types.type_id')
                ->join('Users', 'Materiels.user_id', '=', 'Users.id')
                ->join('Journal_etat_materiels', 'Materiels.mat_code', '=', 'Journal_etat_materiels.mat_code')
                ->select(
                    'Materiels.id',
                    'Materiels.mat_code',
                    'Materiels.mat_designation',
                    'Materiels.mat_ns',
                    'Materiels.imei1',
                    'Materiels.imei2',
                    'Types.type_designation',
                    'Materiels.mat_description',
                    'Materiels.mat_carac',
                    'Materiels.note',
                    'Users.username',
                    'Materiels.mat_date'
                )
                ->whereNotIn('Materiels.mat_code', explode(' ', $request->mat_codes));

        return DataTables::of($data)
            ->addColumn('check', function ($check) {
                return '<input type="checkbox" required="required" name="check" class="check" id="' . $check->id . ' value="' . $check->id . '">';
            })
            ->rawColumns(['check'])
            ->make(true);
    }
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda