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; } }