63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\InteractsWithUuid;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Procedure extends Model
|
|
{
|
|
use HasFactory, InteractsWithUuid;
|
|
|
|
protected $table = 'm_procedure';
|
|
protected $primaryKey = 'id';
|
|
public $incrementing = false;
|
|
protected $keyType = 'string';
|
|
|
|
protected $fillable = [
|
|
'id',
|
|
'code',
|
|
'name',
|
|
'category',
|
|
'description',
|
|
'base_price',
|
|
'is_taxable',
|
|
'tax_percentage',
|
|
'is_discountable',
|
|
'requires_approval',
|
|
'is_active'
|
|
];
|
|
|
|
public function getFinalPriceAttribute(): float
|
|
{
|
|
return $this->is_taxable
|
|
? $this->base_price * (1 + $this->tax_percentage / 100)
|
|
: $this->base_price;
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
|
|
public function scopeWithoutApproval($query)
|
|
{
|
|
return $query->where('requires_approval', false);
|
|
}
|
|
|
|
public static function getCategories(): array
|
|
{
|
|
return [
|
|
'Konsultasi',
|
|
'Pemeriksaan',
|
|
'Tindakan',
|
|
'Operasi',
|
|
'Laboratorium',
|
|
'Radiologi',
|
|
'Obat',
|
|
'Lainnya'
|
|
];
|
|
}
|
|
}
|