Custom Bulkaction generate duplicate queries

Hi i'm trying to add a custom bulkaction to a products table but i'm getting duplicate queries here's my code public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name'), ]) ->bulkActions([ Tables\Actions\BulkAction::make('bulk_updates') ->action(function ($livewire, $data, $records) { //... }) ->form( function ($records, $data) { return [ Forms\Components\Select::make('periode') ->label('Période') ->options(fn () => Periode::pluck('name', 'id')) ->required(), ]; } ), ]); } am i doing something wrong here ?
32 Replies
Mambi
MambiOP2y ago
@Dan Harrin any suggestion please ?
Dan Harrin
Dan Harrin2y ago
i dont have any suggestions, sorry
awcodes
awcodes2y ago
The code you posted seems ok. But I feel like you’re not showing something that could be the cause.
toeknee
toeknee2y ago
I agree with awcodes, post your entire class. If you have filters for example that are not arrow functions it will repeat and so on.
Mambi
MambiOP2y ago
@awcodes @toeknee_iom here's the class class ProduitResource extends Resource { protected static ?string $model = Produit::class; protected static ?string $navigationIcon = 'heroicon-o-collection'; public static function form(Form $form): Form { return $form ->schema([ Card::make()->schema([ Forms\Components\TextInput::make('name') ->required() ->maxLength(255), ]) ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name'), ]) ->bulkActions([ Tables\Actions\BulkAction::make('bulk_updates') ->action(function ($livewire, $data, $records) { //... }) ->form( function ($records, $data) { return [ Forms\Components\Select::make('periode') ->label('Période') ->options(fn () => Periode::pluck('name', 'id')) ->required(), ]; } ), ]); } public static function getRelations(): array { return [ VenteManager::class, ]; } public static function getPages(): array { return [ 'index' => Pages\ListProduits::route('/'), 'create' => Pages\CreateProduit::route('/create'), 'edit' => Pages\EditProduit::route('/{record}/edit'), ]; } }
toeknee
toeknee2y ago
Do you have widgets on the page? I can't replicate so many calls like that, so something else appears to be going on.
Mambi
MambiOP2y ago
@toeknee_iom no widgets on the page
Mambi
MambiOP2y ago
@Dan Harrin @awcodes @toeknee_iom here's on github https://github.com/Mambi/filament.git
GitHub
GitHub - Mambi/filament
Contribute to Mambi/filament development by creating an account on GitHub.
awcodes
awcodes2y ago
Try removing the function in ->form() and just use the array directly ->form([…..])
Mambi
MambiOP2y ago
@awcodes tried but same result
awcodes
awcodes2y ago
Wasn’t sure. I’m really not seeing anything suspicious.
Mambi
MambiOP2y ago
@toeknee_iom any chance ?
awcodes
awcodes2y ago
I’m thinking it might be a recursion issue where you are using a select to load options for the model your resource bulk action is trying to manipulate. What I’m getting at is I don’t understand the select in the form for a bulk action on the same model as your records.
Mambi
MambiOP2y ago
@awcodes even if i change the select with a simple TextInput, i'm getting the same issue
awcodes
awcodes2y ago
What happens if you remove the bulk action completely? Just trying to think of ways to isolate the problem.
Mambi
MambiOP2y ago
@awcodes if i don't use the bulk action i'm getting only 3 queries ,
awcodes
awcodes2y ago
That’s so odd. Can you try a ‘php artisan optimize:clear’ Wish I had a direct answer for you. Sorry. Also, are you using valet?
Mambi
MambiOP2y ago
i did php artisan optimize:clear + php artisan cahce:clear same thing no i'm not using valit
awcodes
awcodes2y ago
Just wondering if there’s a cache somewhere that may be outside filament or laravel. Been having some weird issues with valet myself recently. That’s why I ask.
Mambi
MambiOP2y ago
can you clone the repo and make a test if possible
awcodes
awcodes2y ago
Sure, won’t be tonight, but I can try it tomorrow as long as you have seeders in place so I don’t have to create the data.
Mambi
MambiOP2y ago
i'll add a seeder and let you know
awcodes
awcodes2y ago
Sounds good.
Mambi
MambiOP2y ago
thanks a lot for your time
awcodes
awcodes2y ago
Definitely something odd going on.
Mambi
MambiOP2y ago
yep @awcodes As discussed, i added the ProduitSeeder (with random faker names) + the migration
awcodes
awcodes2y ago
Ok. Just waking up here. Will find some time to look at it today.
Mambi
MambiOP2y ago
great
awcodes
awcodes2y ago
I'm seeing the same on my end with your repo. Not sure why the query is getting called 5 times. Might be a bug.
Mambi
MambiOP2y ago
should i report it as a bug ?
awcodes
awcodes2y ago
sure. and just use that repo for the issue.
Mambi
MambiOP2y ago
ok, once again thanks for your time
Want results from more Discord servers?
Add your server