Skip to content

Add or Update Button while using Action Rule #617

Discussion options

You must be logged in to vote

You can have a Delete and a Restore button and hide them accordingly to your Model state.

use PowerComponents\LivewirePowerGrid\Rules\Rule;
use PowerComponents\LivewirePowerGrid\Header;

final class DishTable extends PowerGridComponent
{

//...

    public function actionRules(): array
    {
        return [

           //Hides delete button when row is trashed
            Rule::button('delete')
              ->when(fn ($dish) => $dish->trashed() == true)
              ->hide(),

           //Hides restore button when row is not trashed
            Rule::button('restore')
              ->when(fn ($dish) => $dish->trashed() == false)
              ->hide(),

         //Change row color for…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@abhaypithadiya
Comment options

@dansysanalyst
Comment options

@abhaypithadiya
Comment options

@luanfreitasdev
Comment options

@abhaypithadiya
Comment options

Answer selected by abhaypithadiya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants