Hi, I'm trying to create a custom event which would log all edits on a table. I'm trying to achive it by custom event. It is working flowlessly when I'm updating 1 row. But if I do bulk edit, it only does the custom event once. But I would need it to do it for all the events. So for example, if I update id 1,2,3,4 with bulk edit only id 1 gets into the log table by custom event.
My question is, is it possible to create an event which would add all?
You will need to explode comma sep ids in case of bulk edit and then perform logging in for loop.
e.g.
$selected_ids = $data["id"];
$ids = explode(",",$selected_ids)
foreach($ids as $id)
{
….
}
Thanks Abu, it is almost perfect now. There is only one more thing I cannot figure out. When I try to insert to the log, only those fields are inserted where I made change in bulk edit. So example I have this in insert within the foreach:
Log::insert([
'progress' => $data["params"]["progress"],
'method' => $data["params"]["method"],
'nga_ticket_nr' => $data["params"]["nga_ticket_nr"],
and I do update only on method, thank progress and nga_ticket_nr fields are not inserted into the log. How could I make it in a way that it inserts every data. (If I do simple update it works, only bulk update does this)
Only non-blank fields are updated in bulk-edit.
I can't guess the issue in your code.
Please email me code / screen recording of issue for review at [email protected]