mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
add bulk confirm
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Filament\OptionsTrait;
|
||||
use App\Filament\Resources\User\UserResource\Pages;
|
||||
use App\Filament\Resources\User\UserResource\RelationManagers;
|
||||
use App\Models\User;
|
||||
use App\Repositories\UserRepository;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Resources\Form;
|
||||
@@ -15,6 +16,8 @@ use Filament\Tables;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class UserResource extends Resource
|
||||
@@ -85,9 +88,7 @@ class UserResource extends Resource
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
// Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
->bulkActions(self::getBulkActions());
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
@@ -108,4 +109,21 @@ class UserResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
public static function getBulkActions(): array
|
||||
{
|
||||
$actions = [];
|
||||
if (Auth::user()->class >= User::CLASS_SYSOP) {
|
||||
$actions[] = Tables\Actions\BulkAction::make('confirm')
|
||||
->label(__('admin.resources.user.actions.confirm_bulk'))
|
||||
->requiresConfirmation()
|
||||
->deselectRecordsAfterCompletion()
|
||||
->action(function (Collection $records) {
|
||||
$rep = new UserRepository();
|
||||
$rep->confirmUser($records->pluck('id')->toArray());
|
||||
});
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -483,4 +483,18 @@ class UserRepository extends BaseRepository
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function confirmUser($id): bool
|
||||
{
|
||||
$update = [
|
||||
'status' => User::STATUS_CONFIRMED,
|
||||
'editsecret' => '',
|
||||
];
|
||||
User::query()
|
||||
->whereIn('id', Arr::wrap($id))
|
||||
->where('status', User::STATUS_PENDING)
|
||||
->update($update);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ return [
|
||||
'grant_prop_form_prop' => 'Select prop',
|
||||
'grant_prop_form_duration' => 'Duration',
|
||||
'grant_prop_form_duration_help' => 'Unit: days. If left blank, the user has it permanently. Note: There is no time limit for Name Change Card, ignore this value.' ,
|
||||
'confirm_bulk' => 'Bulk confirm',
|
||||
]
|
||||
],
|
||||
'exam_user' => [
|
||||
|
||||
@@ -67,6 +67,7 @@ return [
|
||||
'grant_prop_form_prop' => '选择道具',
|
||||
'grant_prop_form_duration' => '有效时长',
|
||||
'grant_prop_form_duration_help' => '单位:天。如果留空,用户永久拥有。注:改名卡没有时间限制,忽略该值。',
|
||||
'confirm_bulk' => '批量确认',
|
||||
]
|
||||
],
|
||||
'exam_user' => [
|
||||
|
||||
@@ -67,6 +67,7 @@ return [
|
||||
'grant_prop_form_prop' => '選擇道具',
|
||||
'grant_prop_form_duration' => '有效時長',
|
||||
'grant_prop_form_duration_help' => '單位:天。如果留空,用戶永久擁有。註:改名卡沒有時間限製,忽略該值。',
|
||||
'confirm_bulk' => '批量確認',
|
||||
]
|
||||
],
|
||||
'exam_user' => [
|
||||
|
||||
Reference in New Issue
Block a user