@@ -24,6 +24,10 @@ class ConflictGuard
|
||||
public function hasConflict(int $userId, ?int $supplierId, ?int $requisitionId): bool
|
||||
{
|
||||
return ConflictDeclaration::query()->where('user_id', $userId)->where('has_conflict', true)
|
||||
->when(app(ConflictReleases::class)->ready(), fn ($query) => $query->whereNotExists(fn ($release) => $release
|
||||
->selectRaw('1')->from('conflict_releases')
|
||||
->whereColumn('conflict_releases.tenant_id', 'conflict_declarations.tenant_id')
|
||||
->whereRaw('conflict_releases.root_id = COALESCE(conflict_declarations.root_id, conflict_declarations.id)')))
|
||||
->where(function ($scopes) use ($supplierId, $requisitionId) {
|
||||
// Supplier-wide statements apply only once that supplier is known.
|
||||
$scopes->where(function ($supplierScope) use ($supplierId) {
|
||||
|
||||
Reference in New Issue
Block a user