PMCORE-1216

This commit is contained in:
Paula Quispe
2020-10-16 15:53:54 -04:00
parent 415b3f19df
commit 2e76cfdeae
15 changed files with 621 additions and 28 deletions

View File

@@ -78,6 +78,30 @@ class Delegation extends Model
return $query->where('DEL_INDEX', '=', $index);
}
/**
* Scope a query to get the started by me
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCaseStarted($query)
{
return $query->where('DEL_INDEX', '=', 1);
}
/**
* Scope a query to get the completed by me
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCaseCompleted($query)
{
return $query->appStatusId(3);
}
/**
* Scope a query to only include a specific delegate date
*
@@ -190,6 +214,17 @@ class Delegation extends Model
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
}
/**
* Scope a query to get the last thread
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeLastThread($query)
{
return $query->where('APP_DELEGATION.DEL_LAST_INDEX', '=', 1);
}
/**
* Scope a query to only include threads without user
*
@@ -411,6 +446,27 @@ class Delegation extends Model
return $query;
}
/**
* Scope the Inbox cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeInboxWithoutUser($query)
{
// This scope is for the join with the APP_DELEGATION table
$query->appStatusId(2);
// Scope for the restriction of the task that must not be searched for
$query->excludeTaskTypes(Task::DUMMY_TASKS);
// Scope that establish that the DEL_THREAD_STATUS must be OPEN
$query->threadOpen();
return $query;
}
/**
* Scope a self service cases
*
@@ -449,6 +505,24 @@ class Delegation extends Model
return $query;
}
/**
* Scope a participated cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $user
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeParticipated($query, $user)
{
// Scope to set the user
$query->userId($user);
// Scope to set the last thread
$query->lastThread();
return $query;
}
/**
* Get specific cases unassigned that the user can view
*