mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Add more filters to user list
This commit is contained in:
@@ -38,6 +38,8 @@ class AdminUserController extends BasePageController
|
||||
'email' => $request->has('email') ? $request->input('email') : '',
|
||||
'host' => $request->has('host') ? $request->input('host') : '',
|
||||
'role' => $request->has('role') ? $request->input('role') : '',
|
||||
'created_from' => $request->has('created_from') ? $request->input('created_from') : '',
|
||||
'created_to' => $request->has('created_to') ? $request->input('created_to') : '',
|
||||
];
|
||||
|
||||
$result = User::getRange(
|
||||
@@ -48,10 +50,12 @@ class AdminUserController extends BasePageController
|
||||
$variables['email'],
|
||||
$variables['host'],
|
||||
$variables['role'],
|
||||
true
|
||||
true,
|
||||
$variables['created_from'],
|
||||
$variables['created_to']
|
||||
);
|
||||
|
||||
$results = $this->paginate($result ?? [], User::getCount($variables['role'], $variables['username'], $variables['host'], $variables['email']) ?? 0, config('nntmux.items_per_page'), $page, $request->url(), $request->query());
|
||||
$results = $this->paginate($result ?? [], User::getCount($variables['role'], $variables['username'], $variables['host'], $variables['email'], $variables['created_from'], $variables['created_to']) ?? 0, config('nntmux.items_per_page'), $page, $request->url(), $request->query());
|
||||
|
||||
// Add country data to each user based on their host IP
|
||||
foreach ($results as $user) {
|
||||
@@ -74,6 +78,8 @@ class AdminUserController extends BasePageController
|
||||
'email' => $variables['email'],
|
||||
'host' => $variables['host'],
|
||||
'role' => $variables['role'],
|
||||
'created_from' => $variables['created_from'],
|
||||
'created_to' => $variables['created_to'],
|
||||
'role_ids' => array_keys($roles),
|
||||
'role_names' => $roles,
|
||||
'userlist' => $results,
|
||||
|
||||
+14
-4
@@ -254,7 +254,7 @@ class User extends Authenticatable
|
||||
self::find($id)->delete();
|
||||
}
|
||||
|
||||
public static function getCount(?string $role = null, ?string $username = '', ?string $host = '', ?string $email = ''): int
|
||||
public static function getCount(?string $role = null, ?string $username = '', ?string $host = '', ?string $email = '', ?string $createdFrom = '', ?string $createdTo = ''): int
|
||||
{
|
||||
$res = self::query()->withTrashed()->where('email', '<>', 'sharing@nZEDb.com');
|
||||
|
||||
@@ -274,6 +274,14 @@ class User extends Authenticatable
|
||||
$res->where('email', 'like', '%'.$email.'%');
|
||||
}
|
||||
|
||||
if ($createdFrom !== '') {
|
||||
$res->where('created_at', '>=', $createdFrom.' 00:00:00');
|
||||
}
|
||||
|
||||
if ($createdTo !== '') {
|
||||
$res->where('created_at', '<=', $createdTo.' 23:59:59');
|
||||
}
|
||||
|
||||
return $res->count(['id']);
|
||||
}
|
||||
|
||||
@@ -382,7 +390,7 @@ class User extends Authenticatable
|
||||
/**
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public static function getRange($start, $offset, $orderBy, ?string $userName = '', ?string $email = '', ?string $host = '', ?string $role = '', bool $apiRequests = false): Collection
|
||||
public static function getRange($start, $offset, $orderBy, ?string $userName = '', ?string $email = '', ?string $host = '', ?string $role = '', bool $apiRequests = false, ?string $createdFrom = '', ?string $createdTo = ''): Collection
|
||||
{
|
||||
if ($apiRequests) {
|
||||
UserRequest::clearApiRequests(false);
|
||||
@@ -391,7 +399,7 @@ class User extends Authenticatable
|
||||
FROM users
|
||||
INNER JOIN roles ON roles.id = users.roles_id
|
||||
LEFT JOIN user_requests ON user_requests.users_id = users.id
|
||||
WHERE users.id != 0 %s %s %s %s
|
||||
WHERE users.id != 0 %s %s %s %s %s %s
|
||||
AND email != 'sharing@nZEDb.com'
|
||||
GROUP BY users.id
|
||||
ORDER BY %s %s %s ";
|
||||
@@ -400,7 +408,7 @@ class User extends Authenticatable
|
||||
SELECT users.*, roles.name AS rolename
|
||||
FROM users
|
||||
INNER JOIN roles ON roles.id = users.roles_id
|
||||
WHERE 1=1 %s %s %s %s
|
||||
WHERE 1=1 %s %s %s %s %s %s
|
||||
ORDER BY %s %s %s';
|
||||
}
|
||||
$order = self::getBrowseOrder($orderBy);
|
||||
@@ -412,6 +420,8 @@ class User extends Authenticatable
|
||||
! empty($email) ? 'AND users.email '.'LIKE '.escapeString('%'.$email.'%') : '',
|
||||
! empty($host) ? 'AND users.host '.'LIKE '.escapeString('%'.$host.'%') : '',
|
||||
(! empty($role) ? ('AND users.roles_id = '.$role) : ''),
|
||||
! empty($createdFrom) ? 'AND users.created_at >= '.escapeString($createdFrom.' 00:00:00') : '',
|
||||
! empty($createdTo) ? 'AND users.created_at <= '.escapeString($createdTo.' 23:59:59') : '',
|
||||
$order[0],
|
||||
$order[1],
|
||||
($start === false ? '' : ('LIMIT '.$offset.' OFFSET '.$start))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<!-- Search Filters -->
|
||||
<div class="px-6 py-4 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700">
|
||||
<form method="get" action="{{ url('admin/user-list') }}">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label for="username" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Username</label>
|
||||
<input type="text"
|
||||
@@ -59,6 +59,22 @@
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="created_from" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Registered From</label>
|
||||
<input type="date"
|
||||
id="created_from"
|
||||
name="created_from"
|
||||
value="{{ $created_from ?? '' }}"
|
||||
class="w-full px-3 py-2 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-blue-500 dark:focus:border-blue-400">
|
||||
</div>
|
||||
<div>
|
||||
<label for="created_to" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Registered To</label>
|
||||
<input type="date"
|
||||
id="created_to"
|
||||
name="created_to"
|
||||
value="{{ $created_to ?? '' }}"
|
||||
class="w-full px-3 py-2 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-blue-500 dark:focus:border-blue-400">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex gap-2">
|
||||
<button type="submit" class="px-4 py-2 bg-blue-600 dark:bg-blue-700 text-white rounded-md hover:bg-blue-700 dark:hover:bg-blue-800">
|
||||
|
||||
Reference in New Issue
Block a user