I need to convert this query form PostgreSQL in Eloquent but I failed:
select
invoice_item_id
from
(
select
invoice_item_id,
status,
row_number() over (partition by invoice_item_id order by id) as rank,
lead(invoice_item_id) over (partition by invoice_item_id) as next
from payment_invoice_item_status as piis
where invoice_item_id > 6000000
and status in (3191,3238)
)d
where status=3191 and rank=1 and next isnull
order by invoice_item_id
I saw fromSub was supported in Laravel 5 but in Laravel 8 there is no such thing. I tried different ways to convert this but non work. How can I convert it?