init project
This commit is contained in:
74
app/Models/Patient.php
Normal file
74
app/Models/Patient.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use App\Enums\RecordStatusEnum;
|
||||
use DateTime;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use App\Traits\AuditLogTrait;
|
||||
|
||||
class Patient extends BaseModel
|
||||
{
|
||||
public $timestamps = false;
|
||||
use HasFactory;
|
||||
use AuditLogTrait;
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $fillable =
|
||||
[
|
||||
'name_en',
|
||||
'dob',
|
||||
'patient_uuid',
|
||||
'gender',
|
||||
'marital_status',
|
||||
'phone_number',
|
||||
'khid_number',
|
||||
'house_number',
|
||||
'street_number',
|
||||
'province_id',
|
||||
'district_id',
|
||||
'commune_id',
|
||||
'village_id',
|
||||
'lab_id',
|
||||
self::CREATED_AT_FIELD,
|
||||
self::CREATED_BY_FIELD,
|
||||
self::UPDATED_BY_FIELD,
|
||||
BaseModel::RECORD_STATUS_FIELD
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
public function province(){
|
||||
return $this->belongsTo(Province::class,'province_id','id');
|
||||
}
|
||||
|
||||
public function district(){
|
||||
return $this->belongsTo(District::class,'district_id','id');
|
||||
}
|
||||
|
||||
public function commune(){
|
||||
return $this->belongsTo(Commune::class,'commune_id','id');
|
||||
}
|
||||
|
||||
public function village(){
|
||||
return $this->belongsTo(Village::class,'village_id','id');
|
||||
}
|
||||
|
||||
public function samples(){
|
||||
return $this->hasMany(Sample::class,'patient_id','id')
|
||||
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => Session::get('base_lab_id')]);
|
||||
}
|
||||
|
||||
public function telegramChatId(){
|
||||
return $this->belongsTo(PatientTelegram::class,'id', 'patient_id');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user