add tests batch 20
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Services\Roles;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\Staff;
|
||||
use App\Models\User;
|
||||
use App\Models\UserRole;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -10,7 +11,9 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RoleAssignmentService
|
||||
{
|
||||
public function __construct(private RoleStaffService $staffService) {}
|
||||
public function __construct(private RoleStaffService $staffService)
|
||||
{
|
||||
}
|
||||
|
||||
/** @param int[] $roleIds */
|
||||
public function assignRoles(int $userId, array $roleIds, ?int $adminId = null): array
|
||||
@@ -18,7 +21,7 @@ class RoleAssignmentService
|
||||
$roleIds = array_values(array_unique(array_filter(array_map('intval', $roleIds), fn ($id) => $id > 0)));
|
||||
|
||||
$user = User::query()->find($userId);
|
||||
if (! $user) {
|
||||
if (!$user) {
|
||||
return ['ok' => false, 'message' => 'User not found.'];
|
||||
}
|
||||
|
||||
@@ -35,7 +38,7 @@ class RoleAssignmentService
|
||||
}
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Role assignment failed: '.$e->getMessage());
|
||||
Log::error('Role assignment failed: ' . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user