diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 687937a..84be6f8 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -22,6 +22,7 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { + $schedule->job(DeleteOldCustomers::class)->dailyAt('22:50'); } /** diff --git a/app/Jobs/DeleteOlds/DeleteOldCustomers.php b/app/Jobs/DeleteOlds/DeleteOldCustomers.php new file mode 100644 index 0000000..8be5666 --- /dev/null +++ b/app/Jobs/DeleteOlds/DeleteOldCustomers.php @@ -0,0 +1,23 @@ +withTrashed()->where('last_connection', '<=', now()->subMonths(36))->forceDelete(); + } +} diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 1639baf..bea08e4 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -70,6 +70,9 @@ class Customer extends Authenticatable implements MustVerifyEmail static::updating(function (self $model) { static::assertEmailIsUnique($model->id, $model->email); }); + static::deleting(function () { + throw new \RuntimeException('This cannot be done à cause de MesBR'); + }); static::deleted(function (self $model) { if ($model->forceDeleting) { if ($model->existsInCrm()) {