Skip to content

ban:delete-expired doesn't work correctly with extend of Ban model. #100

@PowerPeps

Description

@PowerPeps

Laravel 12.28.1
laravel-ban 4.10
PHP 8.4.13


How to reproduce :

Requirements :

  • Create \App\Models\Ban extend \Cog\Laravel\Ban\Models\Ban. (I just add on it the fillable field preset_id).
  • Bind the model in AppServiceProvider like this : $this->app->bind(BanContract::class, \App\Models\Ban::class);
  • Implement Bannable trait in the user model. (like documentation).

How to use :
To create ban with preset_id use :

  $ban = new \App\Models\Ban($data);
  $ban->bannable()->associate($bannable);
  $ban->save();

If you create a ban, and you wait the time of ban, and execute the php artisan ban:delete-expired command, the ban are perfectly softdelete but the flag "banned_at" has not.
As a result, the isBanned() methode are true even though the ban is soft delete in the DB.


I assume that the issue lies with Cog\Laravel\Ban\Observers\BanObserver line 62 verification, which is performed before the data are really updated in database, but i'm not sure.

Has anyone else encountered this problem and found a suitable solution?

**edit :
Some clarification is needed :

  • $data => contains all require data for ban.
  • $bannable => is an instance of a class that can be banned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions