This commit is contained in:
2026-07-01 16:41:06 +07:00
parent e3f2e51232
commit 907b3b2aec
9 changed files with 561 additions and 69 deletions

View File

@@ -1,27 +0,0 @@
<?php
namespace App\Models;
use App\Enums\RecordStatusEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Organism extends BaseModel
{
public $timestamps = false;
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $fillable = ['name_en', 'weight', 'is_bold', 'organization_id'];
public static function boot()
{
parent::boot();
}
public function lab(){
return $this->belongsTo('App\Models\Organization', 'organization_id','id');
}
}

51
app/Models/Pathogen.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
namespace App\Models;
use App\Enums\RecordStatusEnum;
use App\Models\Traits\HasLocalizedName;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\Session;
use App\Traits\AuditLogTrait;
class Pathogen extends BaseModel
{
public $timestamps = false;
use HasFactory;
use HasLocalizedName;
use AuditLogTrait;
/**
* The table associated with the model.
*
* @var string
*/
protected $appends = ['name'];
protected $primaryKey = 'id';
protected $fillable = [
'pathogen_category_concept_id','scientific_name', 'common_name', 'risk_group_concept_id',
'biosafety_level_concept_id', 'infectious_dose', 'transmission_mode', 'storage_requirement', 'min_temp', 'max_temp',
BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD,
BaseModel::DELETED_AT_FIELD, BaseModel::DELETED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
];
public static function boot()
{
parent::boot();
}
public function pathogenType(){
return $this->belongsTo(Concept::class, 'pathogen_category_concept_id', 'id');
}
public function riskGroup(){
return $this->belongsTo(Concept::class, 'risk_group_concept_id', 'id');
}
public function bsl(){
return $this->belongsTo(Concept::class, 'biosafety_level_concept_id', 'id');
}
}

View File

@@ -1,38 +0,0 @@
<?php
namespace App\Models;
use App\Enums\RecordStatusEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\Session;
class SampleType extends BaseModel
{
public $timestamps = false;
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table='sample_types';
protected $fillable = ['name_en', 'weight', 'department_id','tube','description','organization_id','bg_color','color', 'enter_form_id', 'preview_form_id'];
public static function boot()
{
parent::boot();
}
public function department(){
return $this->belongsTo(Department::class, 'department_id');
}
public function testSamples(){
return $this->hasMany(TestSample::class, 'sample_type_id')
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
//->where('organization_id', Session::get('base_organization_id'))
->orderBy('weight');
}
}