PMCORE-3087

This commit is contained in:
Paula Quispe
2021-07-15 12:27:44 -04:00
parent d4adc42138
commit 8c75722801
9 changed files with 296 additions and 110 deletions

View File

@@ -2008,4 +2008,54 @@ class Delegation extends Model
}
return false;
}
/**
* Get cases completed by specific user
*
* @param int $userId
* @param int $offset
* @param int $limit
*
* @return array
*/
public static function casesCompletedBy(int $userId, int $offset = 0, int $limit = 15)
{
// Get the case numbers related to this filter
$query = Delegation::query()->select(['APP_NUMBER']);
// Filter the user
$query->participated($userId);
// Filter the last thread
$query->lastThread();
// Apply the limit
$query->offset($offset)->limit($limit);
// Get the result
$results = $query->get();
return $results->values()->toArray();
}
/**
* Get cases started by specific user
*
* @param int $userId
* @param int $offset
* @param int $limit
*
* @return array
*/
public static function casesStartedBy(int $userId, int $offset = 0, int $limit = 15)
{
// Get the case numbers related to this filter
$query = Delegation::query()->select(['APP_NUMBER']);
// Filter the user
$query->participated($userId);
// Filter the first thread
$query->caseStarted();
// Apply the limit
$query->offset($offset)->limit($limit);
// Get the result
$results = $query->get();
return $results->values()->toArray();
}
}