I have 2 models(market,price_item), i want return last prices for each item (model 2) for 1 market (model 1).
i have in my model 1:
public function prices()
{
return $this->hasMany(MarketPrices::class, self::IDMarket)->groupBy(['item']);
}
This solution give me price for each item but not last price. I tried orderBydesc but not work.
Thanks you for your help