@@ -15,6 +15,27 @@ use Illuminate\Support\Facades\Schema;
|
||||
/** Read-only workdesk over the existing request, event and reservation journals. */
|
||||
class WarehouseWorkdesk
|
||||
{
|
||||
/** @param array<string,mixed> $filters
|
||||
* @return Builder<WarehouseRequest>
|
||||
*/
|
||||
public function filteredBase(User $actor, array $filters): Builder
|
||||
{
|
||||
$base = $this->visible($actor);
|
||||
if (! empty($filters['warehouse_id'])) {
|
||||
$base->where('warehouse_id', $filters['warehouse_id']);
|
||||
}
|
||||
if (! empty($filters['search'])) {
|
||||
$search = trim($filters['search']);
|
||||
if (preg_match('/^(?:RA-)?([1-9][0-9]{0,9})$/iD', $search, $match)) {
|
||||
$base->whereKey($match[1]);
|
||||
} else {
|
||||
$base->where(fn ($q) => $q->whereLike('snapshot->requester->name', '%'.$search.'%')->orWhereLike('snapshot->destination', '%'.$search.'%'));
|
||||
}
|
||||
}
|
||||
|
||||
return $base;
|
||||
}
|
||||
|
||||
public function canView(User $actor, WarehouseRequest $request): bool
|
||||
{
|
||||
return $actor->tenant_id === $request->tenant_id && (
|
||||
|
||||
Reference in New Issue
Block a user