50 lines
1.0 KiB
PHP
50 lines
1.0 KiB
PHP
<?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 Prescription extends Model
|
|
{
|
|
use HasUserStamps;
|
|
|
|
protected $fillable = [
|
|
'patient',
|
|
'issue_date',
|
|
'issue_datetime',
|
|
'doctor',
|
|
'medication_ids',
|
|
'content',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'issue_datetime' => 'datetime',
|
|
'medication_ids' => 'array',
|
|
'created_at' => JalaliDatetime::class,
|
|
'updated_at' => JalaliDatetime::class,
|
|
];
|
|
}
|
|
|
|
public function patientRecord(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Patient::class, 'patient');
|
|
}
|
|
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function updator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'updated_by');
|
|
}
|
|
}
|