@@ -45,6 +45,20 @@ final class CapitalRegister
|
||||
->when($actor->departmentScoped(), fn ($q) => $q->where('data->department_id', $actor->department_id));
|
||||
}
|
||||
|
||||
/** Native read scope for cross-module metadata search; never locks or changes the register.
|
||||
* @return Builder<SupplyRecord>|null
|
||||
*/
|
||||
public function searchQuery(User $actor): ?Builder
|
||||
{
|
||||
if (! $this->ready() || auth()->id() !== $actor->id || $actor->tenant_id === null
|
||||
|| app(OrganizationAccess::class)->maintenanceOnly($actor)
|
||||
|| ! $actor->hasFunctions(['admin', 'warehouse', 'procurement', 'finance', 'department_head'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->visible($actor)->where('tenant_id', $actor->tenant_id);
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function workspace(User $actor, ?string $historyKey = null): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user