Skip to content

Hide link/button in table based on column value #2859

Answered by tabuna
altafsayani asked this question in Q&A
Discussion options

You must be logged in to vote

To hide or show a button based on the value of a column, you can use the canSee method. This method allows you to control the visibility of elements based on specific conditions. Here are a few simple examples without encapsulation:

// This button will always be hidden
Button::make('issue')->canSee(false); 

// This button will be visible only if the status is not 'issued'
Button::make('issue')->canSee($model->status !== 'issued'); 

These examples demonstrate how you can manage the visibility of buttons based on values in your model.

This is explained in more detail in the documentation for fields, but you can use this method in other places as well, such as fields, links, or layouts.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by altafsayani
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants