F
Filament2mo ago
achraf

video

I want to add a button in infolist to toggle a boolean
9 Replies
achraf
achrafOP2mo ago
I did not understand how to create a custom action to change the value of my boolean
LeandroFerreira
LeandroFerreira2mo ago
what is the goal?
achraf
achrafOP2mo ago
I have images in my resource the goal is to add a button to validate these images
LeandroFerreira
LeandroFerreira2mo ago
share some code that you are using please
achraf
achrafOP2mo ago
achraf
achrafOP2mo ago
in the tab of deal I have images and vedios I want to add two buttons to validate the images and the vedios
LeandroFerreira
LeandroFerreira2mo ago
I think you can create custom actions and inject $record to handle this
Actions::make([
Action::make('validate')
->action(function (YourModel $record) {
//...
})
])
Actions::make([
Action::make('validate')
->action(function (YourModel $record) {
//...
})
])
achraf
achrafOP2mo ago
Actions::make([ Action::make('toggleValidImages') ->label(fn ($record) => $record->deal->valid_images ? 'Set Invalid' : 'Set Valid') ->action(function (Request $record) { // Assuming there's a 'deal' relationship on 'Request' $deal = $record->deal; $deal->valid_images = !$deal->valid_images; $deal->save(); }) ->icon(fn ($record) => $record->deal->valid_images ? 'heroicon-s-check' : 'heroicon-s-check') ->color('success') ]) ->visible(fn ($record) => $record->deal !== null) ]), this is my final code and It working thanks for your help
Want results from more Discord servers?
Add your server