Price::select('price.id', 'price.market_id', 'markets.title', 'price.value')
->leftJoin('markets', 'markets.id', '=', 'price.market_id')
->where('price.status', 1)
->groupBy('price.market_id')
->get();
Price::select('price.id', 'price.market_id', 'markets.title', 'price.value')
->leftJoin('markets', 'markets.id', '=', 'price.market_id')
->whereIn('price.id', function($query) {
$query->select(DB::raw('MAX(id)'))
->from(with(new Price)->getTable())
->groupBy('market_id');
})
->where('markets.status', 1)
->where('price.status', 1)
->get();