Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many bans? how? #17

Open
vesper8 opened this issue Jan 19, 2018 · 1 comment
Open

many bans? how? #17

vesper8 opened this issue Jan 19, 2018 · 1 comment
Labels

Comments

@vesper8
Copy link

vesper8 commented Jan 19, 2018

Hi there!

Just checking out this new package after you told me about it on your Love package.. I'm going to be using both of course :)

I also mentioned I was looking for a tool to handle per-user bans/blocks. To tell you the truth I'm working on a dating site so you can imagine it needs all these functionalities

As soon as I started reading the features of this package, the very first one you mention is "models can have many bans" and immediately in my head I started thinking I could use this not only to handle full-on bans in my application, but I could also use it to handle "reports" in a way.

In the sense that, if one user gets reported for abuse by another user.. then he isn't banned yet, but if 3 users report him, then that converts into a ban

I thought your "many bans" implied that I could set a threshold where the user would only get banned after x number of bans had been applied to it.

Is that not at all what you meant?

It would be nice to write a little more about this mysterious feature that made it to the top of the list =D

Another small thing so I don't create an issue for it.. I'm confused about what you mean in the "Scope auto-apply" section. Do you mean that we have to add the shouldApplyBannedAtScope => true if we want to always apply the withoutBanned() by default on all queries on the bannable model?

Big thanks for putting all this love into these packages of course :) extremely handy and useful!

@antonkomarev
Copy link
Member

antonkomarev commented Jan 19, 2018

Hello @vesper8!

We have some kind of projects with functionality you described. They are using Laravel Love & Laravel Ban packages too.

You are right. This package allows Bannable model to have many bans. But it's not designed to be responsible for the Report system. It could be integrated with Report system by utilizing events. When entity has many reports on it - it should be banned. If entity will be unbanned over time or manually - its reports count will be dropped.

The main idea of having multiple ban records is detailed ban history, but additionally it gives ability to:

  • implement permanent ban in the future when user has more than X bans.
  • fire some kind of special events which tell that this entity is problematic: "has reached 10 bans for one year".

You are right about scope auto-apply. If this method will return true - all eloquent queries will include condition that model should not be banned by adding $query->whereNull('banned_at') to them. You will have to use withBanned() or onlyBanned() methods to be able to fetch banned records again.

We need to think more about method naming in future for clear understanding what it stands for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants