chore: code refactor via rector

This commit is contained in:
idevakk
2025-11-14 02:01:01 -08:00
parent 90ab79b3a2
commit ae795880ed
148 changed files with 1520 additions and 1486 deletions

View File

@@ -2,6 +2,10 @@
namespace App\Filament\Pages;
use BackedEnum;
use UnitEnum;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use App\Models\ActivationKey;
use App\Models\Plan;
use Filament\Actions\BulkAction;
@@ -19,17 +23,16 @@ use Filament\Tables\Filters\SelectFilter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Response;
use Str;
class GenerateActivationKeys extends Page implements HasForms, HasTable
{
use InteractsWithForms, InteractsWithTable;
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-key';
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-key';
protected string $view = 'filament.pages.generate-activation-keys';
protected static string|\UnitEnum|null $navigationGroup = 'Admin';
protected static string|UnitEnum|null $navigationGroup = 'Admin';
protected static ?string $title = 'Activation Keys';
@@ -59,13 +62,13 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
];
}
public function generate()
public function generate(): void
{
$data = $this->form->getState();
$plan = Plan::findOrFail($data['plan_id']);
$plan = Plan::query()->findOrFail($data['plan_id']);
for ($i = 0; $i < $data['quantity']; $i++) {
ActivationKey::create([
ActivationKey::query()->create([
'price_id' => $plan->pricing_id,
'activation_key' => strtoupper('Z'.Str::random(16)),
'is_activated' => false,
@@ -99,8 +102,8 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
TextColumn::make('billing_interval')
->label('Interval')
->getStateUsing(function ($record) {
$isMonthly = Plan::where('pricing_id', $record->price_id)->value('monthly_billing');
->getStateUsing(function ($record): string {
$isMonthly = Plan::query()->where('pricing_id', $record->price_id)->value('monthly_billing');
return $isMonthly ? 'Monthly' : 'Yearly';
}),
@@ -121,7 +124,7 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
SelectFilter::make('price_id')
->label('Plan')
->options(
Plan::pluck('name', 'pricing_id')
Plan::query()->pluck('name', 'pricing_id')
),
];
}
@@ -130,13 +133,13 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
{
return [
BulkAction::make('Download Keys')
->action(fn (Collection $records) => $this->downloadKeys($records))
->action(fn (Collection $records): BinaryFileResponse => $this->downloadKeys($records))
->deselectRecordsAfterCompletion()
->requiresConfirmation(),
];
}
public function downloadKeys(Collection $records)
public function downloadKeys(Collection $records): BinaryFileResponse
{
$text = $records->pluck('activation_key')->implode("\n");