Logging bulk edit

QuestionsLogging bulk edit
Boján Mihajlov asked 8 years ago

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?

3 Answers
Abu Ghufran answered 8 years ago

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)
{
….
}

Boján Mihajlov answered 8 years ago

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)

Abu Ghufran answered 8 years ago

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]

Your Answer

5 + 5 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?