[Solved] How to Convert this sql query into laravel query builder


$result = DB::table('table as t')
->select('t.product_id', 't.on_hand', 't.created_at')
->join(DB::raw('(SELECT MAX(purchase_id) as pId FROM table Group by product_id) tg'), function($join) {
    $join->on('t.purchase_id', '=', 'tg.pId');
})->get();

1

solved How to Convert this sql query into laravel query builder