我有一个查询生成器,假设它在纯pgsql查询中是这样的
select distinct on(notulen.id) *
from notulen
inner join peserta_rapat on notulen.id=peserta_rapat.id_notulen
inner join transaksi on transaksi.id_notulen=notulen.id
where "transaksi"."status"::text ilike 'DISETUJUI'
and (
"peserta_rapat"."nip" ='197609072003121007'
or "transaksi"."nip_pimpinan" = '197609072003121007'
or "transaksi"."nip_pj" = '197609072003121007'
or "notulen"."nip_notulen" = '197609072003121007'
or "notulen"."nip_sekretaris" = '197609072003121007'
or "notulen"."nip_notulen" = '197609072003121007')
我使用laravel查询生成器构建了相同的概念,但未按预期工作
$t = Notulen::select(DB::raw('distinct on(notulen.id) *,transaksi.id_notulen'))
->join('peserta_rapat','peserta_rapat.id','=','notulen.id')
->join('transaksi','transaksi.id_notulen','=','notulen.id')
->where('transaksi.status', 'ilike', 'Disetujui')
->where(function($andWhere){
$andWhere
->orWhere('peserta_rapat.nip','=',Auth::user()->nip)
->orWhere('transaksi.nip_pimpinan','=',Auth::user()->nip)
->orWhere('transaksi.nip_pj','=',Auth::user()->nip)
->orWhere('notulen.nip_notulen','=',Auth::user()->nip)
->orWhere('notulen.nip_sekretaris','=',Auth::user()->nip)
->orWhere('notulen.nip_notulen','=',Auth::user()->nip);
});
有人可以帮我解决这个问题吗?