cybercog/laravel-ban

Ban expiration event

Sjoerd opened this issue · 4 comments

Hello,
Because I work with spatie/laravel-permission, I'd like to add a rank to a banned user. This works.
But if the ban expires, I would like a query to be executed to remove the rank.
Is this possible?

Hello, @Sjoerrdd! Good question!

All you need is make listener for the event and implement your logic in it. This package include 2 events. You can listen for the event \Cog\Ban\Events\ModelWasUnbanned and do whatever you need.

Hope this helps!

This event has public property $model so it will has the model which was actually unbanned.

Does \Cog\Ban\Events\ModelWasUnbanned also work if the ban is expired? Or only if the model is unbanned?

@Sjoerrdd ModelWasUnbanned calls on Ban model delete. It's called on unban method call, on ban expiration or on manual Ban model delete.