init project
This commit is contained in:
43
app/Models/Department.php
Normal file
43
app/Models/Department.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use App\Enums\RecordStatusEnum;
|
||||
use App\Models\Traits\HasLocalizedName;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class Department extends BaseModel
|
||||
{
|
||||
public $timestamps = false;
|
||||
use HasFactory;
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
|
||||
use HasLocalizedName;
|
||||
|
||||
|
||||
protected $table='departments';
|
||||
|
||||
protected $fillable = ['name_en', 'weight', 'lab_id'];
|
||||
|
||||
protected $appends = ['name'];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
public function lab(){
|
||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
||||
}
|
||||
|
||||
public function samples(){
|
||||
return $this->hasMany(SampleType::class, 'department_id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)->where('lab_id', Session::get('base_lab_id'))
|
||||
->orderBy('weight');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user