mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update: user filter
This commit is contained in:
parent
392c3677bc
commit
550a787c1a
@ -19,17 +19,17 @@ class UserController extends Controller
|
||||
private function filter(Request $request, $builder)
|
||||
{
|
||||
if ($request->input('filter')) {
|
||||
$request->validate([
|
||||
'filter' => 'array',
|
||||
'filter.*.key' => 'required|in:email,transfer_enable,d,expired_at,uuid,token',
|
||||
'filter.*.condition' => 'required|in:>,<,=,>=,<=',
|
||||
'filter.*.value' => 'required'
|
||||
]);
|
||||
foreach ($request->input('filter') as $filter) {
|
||||
if ($filter['key'] === 'email' && $filter['condition'] === '=') {
|
||||
if ($filter['key'] === 'email') {
|
||||
$builder->where($filter['key'], 'like', '%' . $filter['value'] . '%');
|
||||
continue;
|
||||
}
|
||||
if ($filter['key'] === 'invite_by_email') {
|
||||
$user = User::where('email', $filter['value'])->first();
|
||||
if (!$user) continue;
|
||||
$builder->where('invite_user_id', $user->id);
|
||||
continue;
|
||||
}
|
||||
if ($filter['key'] === 'd' || $filter['key'] === 'transfer_enable') {
|
||||
$filter['value'] = $filter['value'] * 1073741824;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class UserFetch extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'filter.*.key' => 'required|in:email,transfer_enable,d,expired_at,uuid,token',
|
||||
'filter.*.key' => 'required|in:id,email,transfer_enable,d,expired_at,uuid,token,invite_by_email,invite_user_id',
|
||||
'filter.*.condition' => 'required|in:>,<,=,>=,<=',
|
||||
'filter.*.value' => 'required'
|
||||
];
|
||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user