tattersoftware / codeigniter4-audits

Lightweight object logging for CodeIgniter 4
MIT License
13 stars 6 forks source link

Beautiful modules #4

Open MisterAnmar opened 3 years ago

MisterAnmar commented 3 years ago

Thank you for all these beautiful modules. I really hope to see tutorials about them they are really a keepers.

Sorry to post here.

MGatner commented 3 years ago

Thanks friend! I definitely intend to add more official docs, including tutorials and even implementation examples with CodeIgniter Playground. There is still a lot of base development I'd like to do though, so for now I'm keeping the docs basic. But I'm happy to answer any questions or provide specific examples of you are running into issues.

MisterAnmar commented 3 years ago

to be honest i wanted to implement AuditTrait not as a plugin but integrated with my code.. I found it hard to understand the different files. My experience with codeIgniter is min.

My case is as follows. When user (add, edit, delete) something i wanted to add a record of userID, MethodName, and tableName, and recordID.

Simple as that. i found your plugin to learn from it. its just too advanced for me lol.

MisterAnmar commented 3 years ago

Just a note. Your repositaries are what exactly missing from Codeigniter4 online resources.

your repositaries are the building blocks for enterprize level systems.

I reallt hope you will consider to write tutorials or videos about each one of them.

Visits, Permits, Audit, AjaxForms, Assets, Alerts.

MGatner commented 3 years ago

No worries! We are all learning.

So if I understand you correctly, you want to add those fields to every record created by your model, or update them when rows are updated? If that's the case that is much simpler since you are only ever working with one table. I would recommend creating a BaseModel that can handle this centrally and then extend the insert and update methods to add to the data before passing it up, e.g. parent::insert($dataWithNewFields)

MGatner commented 3 years ago

Hey thanks again. We're slowly getting some good online tutorials (check out some of the videos at https://www.reddit.com/r/codeigniter). My time is pulled between the main framework development, these modules, and actual CodeIgniter projects. But like I said I hope as the community grows and the codebase stabilizes it will free up some more time for me to flesh these out.

MisterAnmar commented 3 years ago

No worries! We are all learning. I would recommend creating a BaseModel that can handle this centrally and then extend the insert and update methods to add to the data before passing it up, e.g. parent::insert($dataWithNewFields)

Well im using the Build in Model. My first thought was just create a dedicated model to do this and call it after every Insert, ..etc. but its too primetive also it does not count for performance when there are many records inserted at once...

second thought just add the event on each Model which does the job but again too primetive.

im sure im missing something from CI4 features that does allow me to reach to more sound solution, as you have mentioned its simpler.

Thank you again for the hints and the link

Edit.....

By the way AuditTrait can also be used as a Light ActivityFeed with little bit of modification and simple ajax call and JSON return. Just a thought.