feat: initialize Dr-Panel project with patient file number support
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Casts\JalaliDatetime;
|
||||
use App\Traits\HasUserStamps;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Visit extends Model
|
||||
{
|
||||
use HasUserStamps;
|
||||
|
||||
protected $fillable = [
|
||||
'patient',
|
||||
'visit_date',
|
||||
'visit_time',
|
||||
'treatment',
|
||||
'treatment_cost',
|
||||
'payment_type',
|
||||
'paid_amount',
|
||||
'pos_ul',
|
||||
'pos_ll',
|
||||
'pos_ur',
|
||||
'pos_lr',
|
||||
'treatment_description',
|
||||
'doctor',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'treatment_cost' => 'integer',
|
||||
'paid_amount' => 'integer',
|
||||
'pos_ul' => 'integer',
|
||||
'pos_ll' => 'integer',
|
||||
'pos_ur' => 'integer',
|
||||
'pos_lr' => 'integer',
|
||||
'created_at' => JalaliDatetime::class,
|
||||
'updated_at' => JalaliDatetime::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function getRemainedAmountAttribute(): int
|
||||
{
|
||||
return (int) ($this->treatment_cost ?? 0) - (int) ($this->paid_amount ?? 0);
|
||||
}
|
||||
|
||||
public function patientRecord(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Patient::class, 'patient');
|
||||
}
|
||||
|
||||
public function doctorRecord(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Doctor::class, 'doctor');
|
||||
}
|
||||
|
||||
public function treatmentRecord(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Treatment::class, 'treatment');
|
||||
}
|
||||
|
||||
public function paymentTypeRecord(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PaymentType::class, 'payment_type');
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function updator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'updated_by');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user