Comments (3)
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.
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.
@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)
- v3.0 release HOT 1
- Style change log HOT 1
- Set future date for timestamp flags HOT 1
- [CONCEPT] Casts flags HOT 1
- Fire events HOT 19
- Remove force auto-applying global scopes HOT 9
- Add tests for Events firing
- Write about events and observers in README
- Auto-cast flag values HOT 1
- Add Laravel 5.8 support
- New methods naming HOT 1
- [Feature Request] would it be possible to add the "reported" flag ? HOT 1
- Add getQualified***Column method
- undoActivate from HasActiveFlag not working HOT 1
- support laravel 7 HOT 2
- [question] what i do here wrong
- htmlspecialchars() expects parameter 1 to be string, object given HOT 8
- Add support laravel 9 HOT 2
- Remove laravel/legacy-factory dev dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-eloquent-flag.