fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+26 -13
View File
@@ -1,8 +1,10 @@
<?php
namespace App\Services;
use App\Models\User;
use App\Models\InterestRequest;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
/** Reuses approved administration; never changes the global gate or private-record ACL. */
@@ -10,41 +12,52 @@ final class ScopedPortalAdministration
{
public function administrative(?User $actor): bool
{
if (!$actor || !$actor->hasVerifiedEmail()) return false;
if (! $actor || ! $actor->hasVerifiedEmail()) {
return false;
}
$access = app(PortalProfileAccess::class);
if ($access->has($actor, 'auditor')) return false;
if ($access->has($actor, 'auditor')) {
return false;
}
return ($access->superuser($actor) && $access->mfa($actor))
|| ($access->legacyWriteAllowed($actor) && $access->mfa($actor));
}
public function interestOperator(?User $actor): bool
{
if (!$actor || !$actor->hasVerifiedEmail()) return false;
$access=app(PortalProfileAccess::class);
return !$access->has($actor,'auditor') && $access->mfa($actor)
&& ($this->administrative($actor) || DB::table('interest_requests')->where('assigned_to',$actor->id)->whereNull('deleted_at')->exists());
if (! $actor || ! $actor->hasVerifiedEmail()) {
return false;
}
$access = app(PortalProfileAccess::class);
return ! $access->has($actor, 'auditor') && $access->mfa($actor)
&& ($this->administrative($actor) || DB::table('interest_requests')->where('assigned_to', $actor->id)->whereNull('deleted_at')->exists());
}
public function interest(User $actor, InterestRequest $record): bool
{
return $this->interestOperator($actor)
&& ($actor->can('manage-portal') || (int)$record->assigned_to===$actor->id);
&& ($actor->can('manage-portal') || (int) $record->assigned_to === $actor->id);
}
public function interestQuery($query, User $actor): void
/** @param Builder<InterestRequest>|\Illuminate\Database\Query\Builder $query */
public function interestQuery(Builder|\Illuminate\Database\Query\Builder $query, User $actor): void
{
if (!$actor->can('manage-portal')) $query->where('assigned_to',$actor->id);
if (! $actor->can('manage-portal')) {
$query->where('assigned_to', $actor->id);
}
}
public function deskDecision(User $actor, object $request): bool
public function deskDecision(User $actor, \stdClass $request): bool
{
return $actor->can('manage-portal')
|| ($this->administrative($actor) && (int)$request->analyst_id===$actor->id);
|| ($this->administrative($actor) && (int) $request->analyst_id === $actor->id);
}
public function deskCaseDecision(User $actor, string $id): bool
{
return $actor->can('manage-portal') || ($this->administrative($actor)
&& DB::table('desk_requests')->where('case_id',$id)->where('analyst_id',$actor->id)->exists());
&& DB::table('desk_requests')->where('case_id', $id)->where('analyst_id', $actor->id)->exists());
}
}