Giter Club home page Giter Club logo

Comments (7)

rickmacgillis avatar rickmacgillis commented on July 30, 2024 2

I'm working on this issue now. Once I created the sandbox it worked fine with the tests, so I'm trying to find out what's messing things up. It's not Laravel Spark.

I did find out that my test was flawed for ModelWasUnbanned. To make that event trigger, the model needs to be banned first. (That's a good thing that duplicate unbans don't trigger it.)

I'll keep you updated to see what comes of the issue.

EDIT:
I FINALLY figured out the issue! I installed Laravel Ban for the Nova plugin, and to make the Ban model Searchable and Actionable, and make populate $dates with the expired_at and deleted_at items, I extended the model with my own in App\Models. To make it be able to use $user->bans() I also had to override the relationship method. In doing so, the subclass triggered, but the observer did not, even though it extended the parent that was being observed.

So, while I haven't looked, I think Laravel is probably mapping the class name to the events, and it doesn't see the event because the namespacing doesn't match.

  • \App\Models\User gets banned, and creates a new \App\Models\Ban (or deleted it if it's getting unbanned)
  • \Cog\Laravel\Ban\Models\Ban has the observer attached to it. However, Cog\Laravel\Ban\Models\Ban does not match \App\Models\Ban, and so Laravel doesn't know to fire the event.

All tests now pass. I added the Laravel Ban observer to my custom ban for nova, and gave it its own relationship method, thus leaving the original one in place.

Now I'm working on the issue from the OP, as they still don't trigger in Nova. Presumably it has something to do with the problem I just solved. I'll update this thread again once I've finished that.

Edit 2:
In second thought, I'll create a new issue in Nova Ban and link to this one so more people can find the issue if they have it since this side is done.

from laravel-ban.

rickmacgillis avatar rickmacgillis commented on July 30, 2024 1

from laravel-ban.

antonkomarev avatar antonkomarev commented on July 30, 2024 1

@rickmacgillis thank you for such a detailed research you've done! I need to return back to it later to overlook how all the stuff is implemented and if there is a way to avoid such situations in a future.

from laravel-ban.

antonkomarev avatar antonkomarev commented on July 30, 2024

Hi, @rickmacgillis! Thank you for the feedback. That's seems really strange for me. I will be able too look on it a bit later.
Could it be reproduced in tests or sandbox?

from laravel-ban.

rickmacgillis avatar rickmacgillis commented on July 30, 2024

Presumably this issue is related to my old issue #34, but now it doesn't trigger in the live environment. The tests from the old issue still don't work. (Neither the banned or unbanned events)

As for "sandbox", what are you referring to in this case?

from laravel-ban.

antonkomarev avatar antonkomarev commented on July 30, 2024

Thank you for the previous issue link!

As sandbox I meant github public repo with minimum required functionality to reproduce the bug.

from laravel-ban.

rickmacgillis avatar rickmacgillis commented on July 30, 2024

Welcome.

from laravel-ban.

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.