36 lines
977 B
PHP
36 lines
977 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MisSurgicalOperation extends Model
|
|
{
|
|
private const COMPLETED_OPERATION_STATUS_ID = 3;
|
|
|
|
protected $table = 'stt_surgicaloperation';
|
|
protected $primaryKey = 'SurgicalOperationID';
|
|
|
|
public function serviceMedical()
|
|
{
|
|
return $this->belongsTo(MisServiceMedical::class, 'rf_kl_ServiceMedicalID', 'ServiceMedicalID');
|
|
}
|
|
|
|
public function medicalHistory()
|
|
{
|
|
return $this->belongsTo(MisMedicalHistory::class, 'rf_MedicalHistoryID', 'MedicalHistoryID');
|
|
}
|
|
|
|
public function operationPurpose()
|
|
{
|
|
return $this->hasOne(MisOperationPurpose::class, 'rf_SurgicalOperationID', 'SurgicalOperationID');
|
|
}
|
|
|
|
public function scopeCompleted($query)
|
|
{
|
|
return $query->whereHas('operationPurpose', function ($purposeQuery) {
|
|
$purposeQuery->where('rf_OperationStatusID', self::COMPLETED_OPERATION_STATUS_ID);
|
|
});
|
|
}
|
|
}
|