42 lines
854 B
PHP
Executable File
42 lines
854 B
PHP
Executable File
<?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 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');
|
|
}
|
|
}
|