Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda