cybercog / laravel-ban

Laravel Ban simplify blocking and banning Eloquent models.
https://komarev.com/sources/laravel-ban
MIT License
1.07k stars 63 forks source link

Add support for more states #60

Closed imanghafoori1 closed 4 years ago

imanghafoori1 commented 4 years ago

This package is awesome, but it can still be more useful if you allow the user to set other states.

For example: I want to temporarily give my user access privileges only for a week, so I give him a "VIP" state (instead of "banned" state) for a week. Hope you got it.

In an online shop, we can tag a product model, "out_of_stock" or "discount" for a week.

I can do the coding but I do not like to copy and paste someone else 's code as my starter kit. event if MIT On the other hand, it is a big breaking change to create a PR for it. So I if you allow it I use your code as an inspiration to create a new package out of it.

antonkomarev commented 4 years ago

Why only the user model? support for other models to have temporary "tags" can be added.

As documentation states: "Use case is not limited to User model, any Eloquent model could be banned: Organizations, Teams, Groups and others."

This achieved using morphs columns:

$table->morphs('bannable');

This package was developed to restrict access, not to promote or change visibility option of the model.

Feel free to use this package as boilerplate to create new package to satisfy your requirements.

imanghafoori1 commented 4 years ago

Yeah, I saw it afterward. But other types of tags could be nice. Thank you for responding

imanghafoori1 commented 4 years ago

This was born as a result, you may not see very similarity though

https://github.com/imanghafoori1/laravel-temp-tag