9 Replies
I did not understand how to create a custom action to change the value of my boolean
what is the goal?
I have images in my resource the goal is to add a button to validate these images
share some code that you are using please
in the tab of deal I have images and vedios I want to add two buttons to validate the images and the vedios
I think you can create custom actions and inject
$record
to handle this
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