45 lines
894 B
PHP
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');
|
|
}
|
|
}
|