prices->where('priceable_id', $this->id)->max('price_net'); } public function getPricesGroupOneAttribute() { $orgPrices = []; foreach ($this->prices->where('price_group_id', 1) as $price) { $orgPrices[$this->service_code] = $price->price_net; } return $orgPrices; } public function prices() { return $this->morphMany(Price::class, 'priceable'); } }