api get person/doctor by speciality

This commit is contained in:
Muhammad Fajar
2022-10-28 15:03:21 +07:00
parent 03fdf2684d
commit e025675210
4 changed files with 59 additions and 17 deletions

View File

@@ -18,25 +18,22 @@ class Practice extends Model
'deleted_by'
];
// public $appends = [
// 'price'
// ];
// public function getPriceAttribute()
// {
// $orgPrice = [];
// foreach ($this->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 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');