Skip to content

Commit 845da14

Browse files
committed
Merge branch 'main' into v3
# Conflicts: # routes/web.php
2 parents a993438 + a2f8b0d commit 845da14

77 files changed

Lines changed: 3970 additions & 1208 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\User;
6+
use Illuminate\Console\Command;
7+
8+
class GeneratePluginLicenseKeys extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'plugins:generate-license-keys
16+
{--force : Regenerate keys for all users, even those who already have one}';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Generate plugin license keys for all users who do not have one';
24+
25+
/**
26+
* Execute the console command.
27+
*/
28+
public function handle(): int
29+
{
30+
$force = $this->option('force');
31+
32+
$query = User::query();
33+
34+
if (! $force) {
35+
$query->whereNull('plugin_license_key');
36+
}
37+
38+
$count = $query->count();
39+
40+
if ($count === 0) {
41+
$this->info('All users already have plugin license keys.');
42+
43+
return self::SUCCESS;
44+
}
45+
46+
$this->info("Generating plugin license keys for {$count} users...");
47+
48+
$bar = $this->output->createProgressBar($count);
49+
$bar->start();
50+
51+
$query->chunkById(100, function ($users) use ($bar) {
52+
foreach ($users as $user) {
53+
$user->getPluginLicenseKey();
54+
$bar->advance();
55+
}
56+
});
57+
58+
$bar->finish();
59+
$this->newLine();
60+
61+
$this->info("Generated plugin license keys for {$count} users.");
62+
63+
return self::SUCCESS;
64+
}
65+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Jobs\SyncPlugin;
6+
use App\Models\Plugin;
7+
use Illuminate\Console\Command;
8+
9+
class SyncPlugins extends Command
10+
{
11+
protected $signature = 'plugins:sync';
12+
13+
protected $description = 'Dispatch jobs to sync all plugins from their repositories';
14+
15+
public function handle(): int
16+
{
17+
$plugins = Plugin::all();
18+
19+
$count = $plugins->count();
20+
21+
if ($count === 0) {
22+
$this->info('No plugins to sync.');
23+
24+
return self::SUCCESS;
25+
}
26+
27+
$this->info("Dispatching sync jobs for {$count} plugins...");
28+
29+
$plugins->each(fn (Plugin $plugin) => SyncPlugin::dispatch($plugin));
30+
31+
$this->info('Done. Jobs have been dispatched to the queue.');
32+
33+
return self::SUCCESS;
34+
}
35+
}

‎app/Enums/GrandfatheringTier.php‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎app/Enums/PluginTier.php‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
enum PluginTier: string
6+
{
7+
case Bronze = 'bronze';
8+
case Silver = 'silver';
9+
case Gold = 'gold';
10+
11+
public function label(): string
12+
{
13+
return match ($this) {
14+
self::Bronze => 'Bronze',
15+
self::Silver => 'Silver',
16+
self::Gold => 'Gold',
17+
};
18+
}
19+
20+
public function description(): string
21+
{
22+
return match ($this) {
23+
self::Bronze => 'Entry-level plugins',
24+
self::Silver => 'Standard plugins',
25+
self::Gold => 'Premium plugins',
26+
};
27+
}
28+
29+
public function color(): string
30+
{
31+
return match ($this) {
32+
self::Bronze => 'warning',
33+
self::Silver => 'gray',
34+
self::Gold => 'success',
35+
};
36+
}
37+
38+
/**
39+
* Get the price amounts (in cents) for each PriceTier.
40+
*
41+
* @return array<string, int>
42+
*/
43+
public function getPrices(): array
44+
{
45+
return match ($this) {
46+
self::Bronze => [
47+
PriceTier::Regular->value => 2900,
48+
PriceTier::Subscriber->value => 900,
49+
],
50+
self::Silver => [
51+
PriceTier::Regular->value => 4900,
52+
PriceTier::Subscriber->value => 1500,
53+
],
54+
self::Gold => [
55+
PriceTier::Regular->value => 9900,
56+
PriceTier::Subscriber->value => 2900,
57+
],
58+
};
59+
}
60+
}

‎app/Enums/PriceTier.php‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
enum PriceTier: string
6+
{
7+
case Regular = 'regular';
8+
case Subscriber = 'subscriber';
9+
case Eap = 'eap';
10+
11+
public function label(): string
12+
{
13+
return match ($this) {
14+
self::Regular => 'Regular',
15+
self::Subscriber => 'Pro/Max Subscriber',
16+
self::Eap => 'Early Access',
17+
};
18+
}
19+
20+
public function description(): string
21+
{
22+
return match ($this) {
23+
self::Regular => 'Standard pricing for all customers',
24+
self::Subscriber => 'Discounted pricing for Pro and Max license holders',
25+
self::Eap => 'Special pricing for Early Access Program customers',
26+
};
27+
}
28+
29+
/**
30+
* Get the priority order for tier selection (lower = higher priority).
31+
* When a user qualifies for multiple tiers, the lowest priced tier wins,
32+
* but this priority helps with display/sorting.
33+
*/
34+
public function priority(): int
35+
{
36+
return match ($this) {
37+
self::Eap => 1,
38+
self::Subscriber => 2,
39+
self::Regular => 3,
40+
};
41+
}
42+
}

‎app/Filament/Resources/PluginBundleResource.php‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,6 @@ public static function form(Form $form): Form
6363
])
6464
->columns(2),
6565

66-
Forms\Components\Section::make('Pricing')
67-
->schema([
68-
Forms\Components\TextInput::make('price')
69-
->label('Bundle Price (in cents)')
70-
->required()
71-
->numeric()
72-
->minValue(100)
73-
->helperText('Enter price in cents. E.g., 4999 = $49.99'),
74-
75-
Forms\Components\Select::make('currency')
76-
->options([
77-
'USD' => 'USD',
78-
])
79-
->default('USD')
80-
->required(),
81-
])
82-
->columns(2),
83-
8466
Forms\Components\Section::make('Included Plugins')
8567
->schema([
8668
Forms\Components\Select::make('plugins')
@@ -139,10 +121,9 @@ public static function table(Table $table): Table
139121
->counts('plugins')
140122
->sortable(),
141123

142-
Tables\Columns\TextColumn::make('price')
124+
Tables\Columns\TextColumn::make('formatted_price')
143125
->label('Bundle Price')
144-
->formatStateUsing(fn (int $state): string => '$'.number_format($state / 100, 2))
145-
->sortable(),
126+
->sortable(query: fn ($query, $direction) => $query->orderBy('price', $direction)),
146127

147128
Tables\Columns\TextColumn::make('retail_value')
148129
->label('Retail Value')
@@ -197,6 +178,7 @@ public static function table(Table $table): Table
197178
public static function getRelations(): array
198179
{
199180
return [
181+
RelationManagers\PricesRelationManager::class,
200182
RelationManagers\PluginsRelationManager::class,
201183
RelationManagers\LicensesRelationManager::class,
202184
];

0 commit comments

Comments
 (0)