Table Actions and making variables more efficient
Interested in any opinions on how people avoid repeating code for issues where a table action, and elements of that are dependent on the status of $record
For example, if:
Obviously a very basic example, but when you start adding a lot more methods, and increasing the complexity of the options, it can feel very cluttered and inefficient.
How do people go about extracting some of this logic for the $record?
4 Replies
you can do:
and add the method
getLabel
on the model, and the same for the tooltipImplementing
getLabel()
on the model might help. There is an interface/contract for this, which I use for Enums;
Thanks for the input...I'm wondering whether there are any approaches that are a bit more encompassing?
The label and tooltip were just for illustration.
What if I've got 12 different methods with variations ?
I could load the functions into a model trait. But I just wanted to check there wasn't an easier way to extract the $record, and re-inject the maniuplated statuses back into all the chainable methods.
there is also
configerUsing
but I think the $record
wont be initialized till the form has been built, other approach it to create a macro it may help, it really depend on your use case π