Create a query in Eloquent

1

How can I convert this query to eloquent (I've tried it and I ask to ask since I have no idea)

select  id from solicitudes where id  not in (select autorizaciones.solicitud_id from autorizaciones)
    
asked by jose angarita 01.03.2018 в 23:07
source

1 answer

3

This can be worth to you:

DB::table('solicitudes')
    ->select('id')
    ->whereNotIn('id', DB::table('autorizaciones')->pluck('id'))
    ->get();

With models:

Solicitud::select('id')
        ->whereNotIn('id', Autorizacion::pluck('id'))
        ->get();
    
answered by 02.03.2018 в 17:10