Фактический результат:
Отображается кнопка «Удалить из авторов» (как при удалении нескольких авторов)< /p>
Ожидаемый результат:
отображается только кнопка «Корзина».
count($records) === 1 ? __('Корзина'): __('Удалить от создателей');
Код: Выделить всё
// bulkActions -> DeleteBulkAction -> label
class CreatorResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $navigationIcon = 'heroicon-o-paint-brush';
protected static ?string $navigationLabel = 'Creators';
protected static ?string $label = 'Creators';
protected static ?string $slug = 'authors';
public static function table(Table $table): Table
{
return $table
->modifyQueryUsing(static function ($query) {
$query->leftJoin('model_has_roles', 'model_has_roles.model_id', '=', 'users.id')
->where('model_has_roles.role_id', '=', UserRole::CREATOR->value);
})
->columns([
TextColumn::make('name')
->searchable()
->sortable(),
])
->actions([
Action::make('trash')
->label('')
->icon('heroicon-o-trash')
->action(static function (User $user) {
return $user->removeRole(UserRole::CREATOR->value);
}),
])
->bulkActions([
DeleteBulkAction::make()
->successNotificationTitle(__('Removed'))
->label(__('Remove from creators'))
->modalHeading(__('Remove users'))
->modalSubmitActionLabel(__('Yes, remove it'))
->action(static function (Collection $records) {
$records->each(static function ($user) {
assert($user instanceof User);
$user->removeRole(UserRole::CREATOR->value);
});
}),
]);
}
public static function getPages(): array
{
return [
'index' => Pages\ListCreators::route('/'),
];
}
}
Подробнее здесь: https://stackoverflow.com/questions/789 ... aravel-php