feat(scanner): add scanner authentication and context services with routes and tests

This commit is contained in:
2026-08-11 14:11:23 -03:00
parent 254faedf2c
commit 3eaa3f8202
12 changed files with 316 additions and 4 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Domains\Auth\Services;
use App\Domains\Auth\Models\User;
use App\Domains\Authorization\Enums\RoleCode;
class ScannerContextService
{
public function load(User $user): User
{
$tenant = $user->tenant()
->with([
'menues' => fn ($query) => $query->whereHas(
'roles',
fn ($query) => $query->where('codigo', RoleCode::Scanner->value)
),
])
->firstOrFail();
$user->setRelation('tenant', $tenant);
return $user;
}
}