Giter Site home page Giter Site logo

Comments (3)

antonkomarev avatar antonkomarev commented on May 20, 2024

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.

from laravel-eloquent-flag.

vesper8 avatar vesper8 commented on May 20, 2024

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? :))

from laravel-eloquent-flag.

antonkomarev avatar antonkomarev commented on May 20, 2024

@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!

from laravel-eloquent-flag.

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.