table row action to run a job?
I'm loocking for a table row action to run a job (script, service class...). I have a job (command) and i want run it with a click of a table row action. I need the record id in the script. i think the biggest challenge is the output of the success/failure message? how can i simply call a script is there an easy way? Something like that:
Does anyone have a tip for me?
Solution:Jump to solution
For example with the action-pattern
$result = (new UpdateJobSearches)->run($record->id)
. Return the data you need and build your response with it.7 Replies
Should it be sync or async/queued?
Hm, i think sync.
What are you currently using? A Command? I'd extract the common logic to a class and call it from both.
It's not really a Filament issue, more of a code structure thing.
Yes, currently a Command. And yes i want it to extract. i don't know, how to start the job or this class from the action and return a message. is there a rudimentary example?
PS: The job searches the relevant rows of the client (multitenancy) and creates or updates relationships between the data records. this takes a few seconds.
i don't know, how to start the job or this class from the action and return a message. is there a rudimentary example?If you extract it, it's just calling your new class.
Solution
For example with the action-pattern
$result = (new UpdateJobSearches)->run($record->id)
. Return the data you need and build your response with it.Ok, i try it. Thx.