spatie / laravel-activitylog

Log activity inside your Laravel app
https://docs.spatie.be/laravel-activitylog
MIT License
5.29k stars 712 forks source link

Option to disable retrieving fresh model #1295

Closed niekbr closed 3 months ago

niekbr commented 4 months ago

I have added an option to the LogOptions in order to disable retrieving a fresh copy of the model. The default behavior is unchanged.

This can be useful if database permissions are limited. For example, when a public facing website is allowed to insert but not select from a privacy-sensitive table.

Let me know if you prefer a different synthax; happy to make improvements

Gummibeer commented 4 months ago

Hey, personally not really a case for it - @freekmurze any opinions if you would like to have it merged in and maintain it? If so I would like to have and see some tests for that one making it clear what it does and what the effects are.

niekbr commented 4 months ago

If this solution is not maintainable; it would also be possible to only extract $processingEvent == 'retrieved' to a separate function in order to be able to overwrite it (without adding it to the LogOptions. Let me know what has your preference. I will add tests if you are open for the PR!