PMCORE-3129
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user