Merged in bugfix/PMCORE-3878 (pull request #8503)

PMCORE-3878

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Paula Quispe
2022-08-08 19:47:09 +00:00
committed by Julio Cesar Laura Avendaño
3 changed files with 36 additions and 0 deletions

View File

@@ -94,6 +94,17 @@ class Delegation extends Model
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
}
/**
* Scope a query to only include open threads
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeThreadIdOpen($query)
{
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS_ID', 1);
}
/**
* Scope a query to only include pause threads
*
@@ -2182,6 +2193,15 @@ class Delegation extends Model
$query = Delegation::query()->select(['APP_NUMBER']);
// Filter the title
$query->title($search);
// Get open or last thread
$query->where(function ($query) {
// Get open threads
$query->threadIdOpen();
// Get last
$query->orWhere(function ($query) {
$query->lastThread();
});
});
// Group by
$query->groupBy('APP_NUMBER');
// Get the result