Allow "Log 1st Flight" achievement to be awarded even if flight is upcoming
This commit is contained in:
@@ -3,19 +3,35 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Attributes\Argument;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('app:recalculate-achivements')]
|
||||
#[Description('Recalculate achievements for all users')]
|
||||
#[Signature('app:recalculate-achievements {username? : The username of a single user to recalculate}')]
|
||||
#[Description('Recalculate achievements for all users, or a single user by username')]
|
||||
class RecalculateAchievements extends Command
|
||||
{
|
||||
public function handle(): void
|
||||
{
|
||||
$users = User::all();
|
||||
foreach ($users as $user) {
|
||||
$username = $this->argument('username');
|
||||
|
||||
if ($username) {
|
||||
$user = User::where('name', $username)->first();
|
||||
|
||||
if (! $user) {
|
||||
$this->error("No user found with username [{$username}].");
|
||||
return;
|
||||
}
|
||||
|
||||
$user->calculateAchievements();
|
||||
$this->info("Recalculated achievements for {$username}.");
|
||||
return;
|
||||
}
|
||||
|
||||
$users = User::all();
|
||||
$this->withProgressBar($users, fn (User $user) => $user->calculateAchievements());
|
||||
$this->newLine();
|
||||
$this->info("Recalculated achievements for {$users->count()} users.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user