PMCORE-3129

This commit is contained in:
Andrea Adamczyk
2021-07-08 09:40:57 -04:00
parent bc169bcd77
commit ef03ffcdd3
6 changed files with 204 additions and 1 deletions

View File

@@ -17,6 +17,18 @@ class ProcessCategory extends Model
public $timestamps = false;
/**
* Scope a query to specific category name
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $name
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCategoryName($query, $name)
{
return $query->where('CATEGORY_NAME', 'LIKE', "%{$name}%");
}
/**
* Get the categories
*
@@ -27,7 +39,7 @@ class ProcessCategory extends Model
* @see ProcessProxy::categoriesList()
* @link https://wiki.processmaker.com/3.0/Process_Categories
*/
public static function getCategories( $dir = 'ASC')
public static function getCategories($dir = 'ASC')
{
$query = ProcessCategory::query()
->select([
@@ -38,4 +50,46 @@ class ProcessCategory extends Model
return $query->get()->values()->toArray();
}
/**
* Get the process categories
*
* @param string $name
* @param int $start
* @param int $limit
*
* @return array
*
* @see ProcessMaker\Services\Api\Home::getCategories()
*/
public static function getProcessCategories($name = null, $start = null, $limit = null)
{
$query = ProcessCategory::query()->select(['CATEGORY_ID', 'CATEGORY_NAME']);
if (!is_null($name)) {
$query->categoryName($name);
}
if (!is_null($start) && !is_null($limit)) {
$query->offset($start)->limit($limit);
}
return $query->get()->toArray();
}
/**
* Get category Id
*
* @param string $categoryUid
*
* @return int
*/
public static function getCategoryId($categoryUid)
{
$query = ProcessCategory::query()->select(['CATEGORY_ID']);
$query->where('CATEGORY_UID', $categoryUid);
if ($query->first()) {
return $query->first()->CATEGORY_ID;
}
}
}