Add Period & Sort options to user access log

This commit is contained in:
Bubka
2024-04-15 18:39:37 +02:00
parent 4f17e2aff0
commit 44d7328d6c
7 changed files with 111 additions and 7 deletions

View File

@@ -216,10 +216,12 @@ class UserManagerController extends Controller
$this->authorize('view', $user);
$validated = $this->validate($request, [
'period' => 'sometimes|numeric',
'limit' => 'sometimes|numeric',
]);
$authentications = $request->has('limit') ? $user->authentications->take($validated['limit']) : $user->authentications;
$authentications = $request->has('period') ? $user->authentications($validated['period'])->get() : $user->authentications->get();
$authentications = $request->has('limit') ? $authentications->take($validated['limit']) : $authentications;
return UserAuthentication::collection($authentications);
}