diff --git a/app/Console/Commands/FixSoftDeletedProfile.php b/app/Console/Commands/FixSoftDeletedProfile.php new file mode 100644 index 000000000..3fe90ff3c --- /dev/null +++ b/app/Console/Commands/FixSoftDeletedProfile.php @@ -0,0 +1,60 @@ +withTrashed() + ->where('deleted_at', '>', now()->subDays(14)) + ->whereNull('status') + ->pluck('username'); + + if($profiles->count() == 0) { + return 0; + } + + foreach($profiles as $p) { + if(User::whereUsername($p)->first()->status == null) { + $pro = Profile::withTrashed()->whereUsername($p)->firstOrFail(); + $pro->deleted_at = null; + $pro->save(); + } + } + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a29ace355..d5e1d47a4 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -31,6 +31,7 @@ class Kernel extends ConsoleKernel ->hourly(); $schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('story:gc')->everyFiveMinutes(); + $schedule->command('fix:sdprofile')->everyFiveMinutes(); $schedule->command('gc:failedjobs')->dailyAt(3); $schedule->command('gc:passwordreset')->dailyAt('09:41'); }