PMCORE-3379

This commit is contained in:
Andrea Adamczyk
2021-09-29 16:28:55 -04:00
parent 6ed4ae566f
commit 436e1e0b04
3 changed files with 270 additions and 42 deletions

View File

@@ -1050,6 +1050,25 @@ class Delegation extends Model
return $query;
}
/**
* Scope a participated user in the case
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $user
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeParticipatedUser($query, $user)
{
// Scope to set the user who participated in the case
$query->whereIn('APP_DELEGATION.APP_NUMBER', function ($query) use ($user) {
$query->select('APP_NUMBER')->from('APP_DELEGATION')
->where('USR_ID', $user)->distinct();
});
return $query;
}
/**
* Get specific cases unassigned that the user can view
*