GithubHelp home page GithubHelp logo

Comments (7)

gisostallenberg avatar gisostallenberg commented on May 23, 2024 1

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.

parallels999 avatar parallels999 commented on May 23, 2024

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.

angeljqv avatar angeljqv commented on May 23, 2024

dcb1a6b, 43fbbe6

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.

MortenDHansen avatar MortenDHansen commented on May 23, 2024

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.

parallels999 avatar parallels999 commented on May 23, 2024

Also #873 would be needed

from laravel-auditing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.