Count when click on table row to view model
Hey! I have a resource table with messages and a simple view modal. How i can set the reat_at date on the model when the message modal was opened?
5 Replies
Why do you need to set the created_at date when the modal is opened as opposed to letting the db set it when the record is created?
Assuming reat_at is a typo. Not sure.
Hey awcodes. My Message model has the columns read_at (nullable), created_at, updated_at. i want to update the read_at when the view modal was opened. Do you know any hooks, or anything else where i can do a: $model->read_at = now(); $model->save(); ?
Hm.. that’s difficult since a view isn’t a form and doesn’t have a form. You might need a custom action that can emit an event and a listener to update the record. Assuming you need to save it somewhere. But if you aren’t persisting it then it shouldn’t matter.
I found a method i can use on the ViewAction class like this:
🥳
Problem solved. 🙂 Thank you for your time awcodes.
Glad you figured it out.