sigd/app/Models/ReferenceEf.php

33 lines
991 B
PHP

<?php
namespace App\Models;
class ReferenceEf extends SigdModel
{
protected $table = 'ef';
protected $fillable = [
'id', 'activity_code', 'tag_1', 'tag_2', 'tag_3', 'category', 'ef_source_code', 'value',
'description', 'active_status', 'row_status', 'created_by', 'updated_by',
];
public function activity()
{
return $this->belongsTo(ReferenceActivity::class, 'activity_code', 'code');
}
public function efSource()
{
return $this->belongsTo(ReferenceEfSource::class, 'ef_source_code', 'code');
}
public function scopeGetValue($query, $activityCode, $category, $tag1 = null, $tag2 = null, $tag3 = null)
{
$output = $query->rowActive()->where('active_status', 1)
->where('activity_code', $activityCode)->where('category', $category)
->where('tag_1', $tag1)->where('tag_2', $tag2)->where('tag_3', $tag3)
->first();
return $output ? $output->value : 0;
}
}