Comments (7)
also, it's not so "automatic"
What do you mean? I meant: If you want to audit specific relationship attach/detachments, you can implement it in the main point where your intention to audit lies, not at various points in your existing codebase. In the documented manner you'd have to change all calls from attach
to auditAttach
.
Not to mention this case, which is not auditing in the documented manner:
$model = MyModel::factory()
->hasAttached($otherModel)
->create();
In the proposed solution this will get audited. I call that automated.
It is only 'automatic' when someone decorates the BelongsToMany, so there is a upgrade path. It is not breaking in any way. Just leave your codebase as is and nothing will happen...
I think I forgot sync, which can be simply added.
I'd have to check if MorphToMany can be an argument to BelongsToManyAudit::audit
. That is one of the reasons I opened an issue before creating a PR.
@parallels999 thanks for your cheerfulness about this issue 😉
from laravel-auditing.
And MorphToMany
? sync()
?
It would also be a breaking change, because everyone should already be using auditSync
, and not to mention that if someone is already using a custom relationship this would already be a conflict,
also, it's not so "automatic"
from laravel-auditing.
I think it's a great idea, but you could no longer decide if you want to audit only the id column
maybe adding some property that indicates which columns should be audited in the relationship
return BelongsToManyAudit::audit($this->belongsToMany(OtherModel::class), [
'audited_column_1', 'audited_column_2'
]);
from laravel-auditing.
I see the idea. Might need to think a bit though.
At first i was reluctant to make the relations audit because the whole concept is basically to audit by the events (audit by model). Using the custom audit is a way to get the job done when you attach a role to a user (or similar), and the supplied methods are basically just a documented workaround for the missing events.
The manual effort of explicitly using the auditSync/attach/detach front methods are actually quite intentional so that it is only used deliberately.
from laravel-auditing.
Also #873 would be needed
from laravel-auditing.
Related Issues (20)
- Integrity constraint violation when model pivot is saved HOT 13
- phpstan error: "Class OwenIt\Auditing\Contracts\OwenIt\Auditing\Contracts\Audit was not found while trying to analyse it"
- User ID and User Type not being added in audits table HOT 1
- ArrayObject::__construct() TypeError
- auditSync - writes an empty array when there is no data change HOT 1
- Error when saving characters in Spanish HOT 5
- Call to undefined method Model::toAudit()
- I have PHP 8.1 and Laravel 10. My error is in the Model: Undefined type: "\OwenIt\Auditing\Auditable" HOT 17
- Record non modified fields HOT 3
- Audit is not created when manually triggering the updated event on model HOT 4
- Serialization of 'PDO' is not allowed - Queued Audits HOT 9
- The [sync] queue connection has not been configured. HOT 5
- Excessive Queue job logged when use with batch import of large amount of data (#846) HOT 3
- Enabling queue causes Unable to JSON encode payload. Error (5) HOT 7
- Audit excludes fields records are creating in table HOT 3
- Class "Request" not found HOT 1
- The events (DispatchAudit) are missing the SerializesModels trait HOT 9
- Serialization of 'Closure' is not allowed HOT 7
- ErrorException: Undefined array key "table" in /vendor/laravel/framework/src/Illuminate/Queue/Connectors/DatabaseConnector.php:38 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-auditing.