COnflicts

This commit is contained in:
Paula Quispe
2021-11-11 16:33:48 -04:00
parent ce9e93a41f
commit b330c3c0b9
13 changed files with 257 additions and 10 deletions

View File

@@ -17,6 +17,18 @@ class ProcessCategory extends Model
public $timestamps = false;
/**
* Scope a query to specific category id
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $category
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCategory($query, $category)
{
return $query->where('CATEGORY_ID', $category);
}
/**
* Scope a query to specific category name
*
@@ -92,4 +104,22 @@ class ProcessCategory extends Model
return $query->first()->CATEGORY_ID;
}
}
/**
* Get category name
*
* @param int $category
*
* @return string
*/
public static function getCategory(int $category)
{
$query = ProcessCategory::query()->select(['CATEGORY_NAME']);
$query->category($category);
if ($query->first()) {
return $query->first()->CATEGORY_NAME;
} else {
return '';
}
}
}