Files
aso/app/Models/Practice.php
Muhammad Fajar 2f84f43ae5 api doctor detail
2022-10-27 14:37:12 +07:00

45 lines
894 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Practice extends Model
{
use HasFactory;
protected $fillable = [
'practitioner_role_id',
'service_code',
'active',
'created_by',
'updated_by',
'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 prices()
{
return $this->morphMany(Price::class, 'priceable');
}
}