60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\OrderStatus;
|
|
use EloquentFilter\Filterable;
|
|
use App\Traits\HasDateTimeFormatter;
|
|
use Slowlyo\OwlAdmin\Models\AdminUser;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
|
/**
|
|
* 病历记录
|
|
*/
|
|
class PatientRecord extends Model
|
|
{
|
|
use HasDateTimeFormatter, Filterable;
|
|
|
|
protected $fillable = ['patient_id', 'type_id', 'treat_at', 'doctor_id', 'content', 'origin_price', 'sell_price', 'order_status', 'notify_at', 'notify_user_id', 'notify_remarks', 'is_notified', 'next_treat_at', 'creator_id'];
|
|
|
|
protected $casts = [
|
|
'order_status' => OrderStatus::class,
|
|
'notify_at' => 'datetime',
|
|
'treat_at' => 'datetime',
|
|
'next_treat_at' => 'datetime',
|
|
'origin_price' => 'float',
|
|
'sell_price' => 'float',
|
|
];
|
|
|
|
public function patient()
|
|
{
|
|
return $this->belongsTo(Patient::class, 'patient_id');
|
|
}
|
|
|
|
public function type()
|
|
{
|
|
return $this->belongsTo(Keyword::class, 'type_id');
|
|
}
|
|
|
|
public function doctor()
|
|
{
|
|
return $this->belongsTo(AdminUser::class, 'doctor_id');
|
|
}
|
|
|
|
public function notifyUser()
|
|
{
|
|
return $this->belongsTo(AdminUser::class, 'notify_user_id');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(AdminUser::class, 'creator_id');
|
|
}
|
|
|
|
public function scopeSort($q)
|
|
{
|
|
return $q->orderBy('treat_at', 'desc');
|
|
}
|
|
}
|