prices as $price) { // $orgPrice[$this->service_code] = $price->price_net; // } // return $orgPrice; // } public function getPriceAttribute() { return $this->prices->where('priceable_id', $this->id)->max('price_net'); } public function prices() { return $this->morphMany(Price::class, 'priceable'); } }