mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
Merge branch 'php8' into section
This commit is contained in:
@@ -163,6 +163,7 @@ class TorrentResource extends Resource
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->setPosState($idArr, $data['pos_state']);
|
||||
} catch (\Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
})
|
||||
@@ -180,6 +181,7 @@ class TorrentResource extends Resource
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->syncTags($idArr);
|
||||
} catch (\Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
})
|
||||
@@ -188,11 +190,13 @@ class TorrentResource extends Resource
|
||||
$actions[] = Tables\Actions\BulkAction::make('attach_tag')
|
||||
->label(__('admin.resources.torrent.bulk_action_attach_tag'))
|
||||
->form([
|
||||
Forms\Components\Checkbox::make('remove')->label(__('admin.resources.torrent.bulk_action_attach_tag_remove_old')),
|
||||
Forms\Components\CheckboxList::make('tags')
|
||||
->label(__('label.tag.label'))
|
||||
->columns(4)
|
||||
->options(TagRepository::createBasicQuery()->pluck('name', 'id')->toArray())
|
||||
->required(),
|
||||
|
||||
])
|
||||
->icon('heroicon-o-tag')
|
||||
->action(function (Collection $records, array $data) {
|
||||
@@ -202,8 +206,9 @@ class TorrentResource extends Resource
|
||||
$idArr = $records->pluck('id')->toArray();
|
||||
try {
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->syncTags($idArr, $data['tags']);
|
||||
$torrentRep->syncTags($idArr, $data['tags'], $data['remove'] ?? false);
|
||||
} catch (\Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -287,8 +287,10 @@ class UserProfile extends Page
|
||||
try {
|
||||
if (!empty($data['duration'])) {
|
||||
$data['deadline'] = now()->addDays($data['duration']);
|
||||
} else {
|
||||
$data['deadline'] = null;
|
||||
}
|
||||
$rep->addMeta($this->record, $data);
|
||||
$rep->addMeta($this->record, $data, $data);
|
||||
$this->notify('success', 'Success!');
|
||||
$this->emitSelf(self::EVENT_RECORD_UPDATED, $this->record->id);
|
||||
} catch (\Exception $exception) {
|
||||
|
||||
Reference in New Issue
Block a user