<?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','lab_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('lab_id', Session::get('base_lab_id'))
            ->orderBy('weight');
    }

}
