initial: bootstrap from BukidBountyApp base
This commit is contained in:
27
app/Console/Commands/ResetAllUsersCommand.php
Normal file
27
app/Console/Commands/ResetAllUsersCommand.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Hypervel\Console\Command;
|
||||
|
||||
class ResetAllUsersCommand extends Command
|
||||
{
|
||||
protected ?string $signature = 'app:reset-users {--message= : Optional toast message shown before reload}';
|
||||
|
||||
protected string $description = 'Queue a browser reload for all users on their next SSE tick (next login or active session).';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$message = $this->option('message') ?: 'App update applied. Reloading...';
|
||||
|
||||
$js = "sessionStorage.clear(); alert('" . addslashes($message) . "'); window.location.reload();";
|
||||
|
||||
$affected = User::whereNotNull('id')->update(['exec_command' => $js]);
|
||||
|
||||
$this->info("Reset command queued for {$affected} users.");
|
||||
$this->line("Command: <comment>{$js}</comment>");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user