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

can this be used for "user-to-many" blocked scenario? #30

Closed
vesper8 opened this issue May 19, 2017 · 3 comments
Closed

can this be used for "user-to-many" blocked scenario? #30

vesper8 opened this issue May 19, 2017 · 3 comments

Comments

@vesper8
Copy link
Contributor

vesper8 commented May 19, 2017

Hi there!

I just found your other package laravel-ban which I plan to use

I'm also looking for a package that will help me implement the following.

I am making a dating site and users can "block" other users. In that case the user would only be able to see users that are not on their block list.

Wondering if with this library you can create custom flags? In my case it would be a "banned" and "banned_at" flag. And does this library support flags that are only applicable to certain users?

With the laravel-ban the ban is applied categorically, but with this library the ban (or block) is only applied to the scope of the logged-in user ?

@antonkomarev
Copy link
Member

antonkomarev commented May 19, 2017

Hello, @vesper8!

Interesting question. I've thought about one abstract global query scope and ability to create custom scopes based on abstract ones but dropped this idea after couple of weeks of planning because it started to become huge and not so simple as it was planned initially. If you have any ideas how to make customizable global query scopes, have an ability to attach many scopes to same Model and still keep it simple will glad to talk about it.

All the flags in this package has effect on all users. If you apply Closed flag to Model - all users will see that model is closed. The only thing you can customize - prevent auto applying query scope by the specified conditions.

For example to prevent auto applying of VerifiedAtFlag you can add in verifiable Model custom method:

public function shouldApplyVerifiedAtScope()
{
    // isNotAdmin is just an example method
    // which should return boolean true for non-admin users
    return auth()->user()->isNotAdmin();
}

Laravel Ban default behavior will block user globally too. So it has the same behavior but additionally has table with ban details with ability to auto-remove ban over time. There is no way to block user for one person only. In theory you could extend Ban model with your functionality and add required relations and checks.

I've implemented functionality you need earlier but package with it is not open source yet. You need a pivot table where all the blocks will be stored (let's say blocked_users) and on each user search you should check that results not exists in this pivot table. It will slow down your database queries for sure.

Feel free to add new Flags in PRs.

@vesper8
Copy link
Contributor Author

vesper8 commented May 19, 2017

Thanks for the details! Well.. as you might imagine.. I'm pretty excited at the prospect of you releasing a new package with your existing functionality that does just what I need :))

I've looked and can't find one that does that. There is this one https://github.com/batuhan/laravel-flaggable which is actually based on your own laravel-likeable but it's old and unmaintained and just doesn't look good

Anyway.. is there any chance you might release this new package soon? :))

@antonkomarev
Copy link
Member

antonkomarev commented May 19, 2017

@vesper8 Sadly I don't have enough time to prepare this package for the release. It's pretty raw, undocumented and tightly coupled with app business logic to reduce database load. I'm spending a lot of my free time dedicated to open source by designing Laravel YouTrack integration and there are more packages planned to release this year. Not sure it could happen earlier than 2018.

You could try to use cybercog/laravel-likeable package then and write your queries that way to hide all disliked users or fork it if some of the parts are missing. I've thought about possibility of this solution but haven't proofed a concept.

Will be glad if you share your results!

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

No branches or pull requests

2 participants