Skip to content

Commit 78490d5

Browse files
committed
refactor: standardize enum naming conventions
- Convert enum cases from UPPER_CASE to PascalCase - Update method names from label() to getLabel() for Filament compatibility - Implement HasLabel and HasColor interfaces consistently - Update all references in forms, tables, factories, and tests - Remove duplicate UserRole enum file - Maintain backward compatibility for enum values
1 parent 0c7f95d commit 78490d5

21 files changed

+260
-218
lines changed

app/Enums/BookingStatus.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,33 @@
22

33
namespace App\Enums;
44

5-
enum BookingStatus: string
5+
use Filament\Support\Contracts\HasColor;
6+
use Filament\Support\Contracts\HasLabel;
7+
8+
enum BookingStatus: string implements HasLabel, HasColor
69
{
7-
case PENDING = 'pending';
8-
case CONFIRMED = 'confirmed';
9-
case CANCELLED = 'cancelled';
10-
case COMPLETED = 'completed';
10+
case Pending = 'pending';
11+
case Confirmed = 'confirmed';
12+
case Cancelled = 'cancelled';
13+
case Completed = 'completed';
1114

12-
public function label(): string
15+
public function getLabel(): string
1316
{
1417
return match ($this) {
15-
self::PENDING => 'Pending',
16-
self::CONFIRMED => 'Confirmed',
17-
self::CANCELLED => 'Cancelled',
18-
self::COMPLETED => 'Completed',
18+
self::Pending => 'Pending',
19+
self::Confirmed => 'Confirmed',
20+
self::Cancelled => 'Cancelled',
21+
self::Completed => 'Completed',
1922
};
2023
}
2124

22-
public function color(): string
25+
public function getColor(): string
2326
{
2427
return match ($this) {
25-
self::PENDING => 'warning',
26-
self::CONFIRMED => 'info',
27-
self::CANCELLED => 'danger',
28-
self::COMPLETED => 'success',
28+
self::Pending => 'warning',
29+
self::Confirmed => 'info',
30+
self::Cancelled => 'danger',
31+
self::Completed => 'success',
2932
};
3033
}
3134
}

app/Enums/BusCategory.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@
99
enum BusCategory: string implements HasColor, HasIcon, HasLabel
1010
{
1111
case Economy = 'economy';
12-
case LUXURY = 'luxury';
13-
case SLEEPER = 'sleeper';
14-
case BUSINESS = 'business';
12+
case Luxury = 'luxury';
13+
case Sleeper = 'sleeper';
14+
case Business = 'business';
1515

1616
public function getLabel(): ?string
1717
{
1818
return match ($this) {
1919
self::Economy => 'Economy',
20-
self::LUXURY => 'Luxury',
21-
self::SLEEPER => 'Sleeper',
22-
self::BUSINESS => 'Business',
20+
self::Luxury => 'Luxury',
21+
self::Sleeper => 'Sleeper',
22+
self::Business => 'Business',
2323
};
2424
}
2525

2626
public function getIcon(): ?string
2727
{
2828
return match ($this) {
2929
self::Economy => 'lucide-coins',
30-
self::LUXURY => 'lucide-gem',
31-
self::SLEEPER => 'lucide-bed',
32-
self::BUSINESS => 'lucide-briefcase-business',
30+
self::Luxury => 'lucide-gem',
31+
self::Sleeper => 'lucide-bed',
32+
self::Business => 'lucide-briefcase-business',
3333
};
3434
}
3535

3636
public function getColor(): string|array|null
3737
{
3838
return match ($this) {
3939
self::Economy => 'gray',
40-
self::LUXURY => 'danger',
41-
self::SLEEPER => 'info',
42-
self::BUSINESS => 'success',
40+
self::Luxury => 'danger',
41+
self::Sleeper => 'info',
42+
self::Business => 'success',
4343
};
4444
}
4545
}

app/Enums/BusType.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@
99

1010
enum BusType: string implements HasColor, HasIcon, HasLabel
1111
{
12-
case AC = 'ac';
13-
case NON_AC = 'non_ac';
12+
case Ac = 'ac';
13+
case NonAc = 'non_ac';
1414

1515
public function getLabel(): ?string
1616
{
1717
return match ($this) {
18-
self::AC => 'AC',
19-
self::NON_AC => 'Non AC',
18+
self::Ac => 'AC',
19+
self::NonAc => 'Non AC',
2020
};
2121
}
2222

2323
public function getIcon(): ?string
2424
{
2525
return match ($this) {
26-
self::AC => LucideIcon::AirVent->value,
27-
self::NON_AC => LucideIcon::Wind->value,
26+
self::Ac => LucideIcon::AirVent->value,
27+
self::NonAc => LucideIcon::Wind->value,
2828
};
2929
}
3030

3131
public function getColor(): string|array|null
3232
{
3333
return match ($this) {
34-
self::AC => 'info',
35-
self::NON_AC => 'gray',
34+
self::Ac => 'info',
35+
self::NonAc => 'gray',
3636
};
3737
}
3838
}

app/Enums/OperatorStatus.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,33 @@
22

33
namespace App\Enums;
44

5-
enum OperatorStatus: string
5+
use Filament\Support\Contracts\HasColor;
6+
use Filament\Support\Contracts\HasLabel;
7+
8+
enum OperatorStatus: string implements HasLabel, HasColor
69
{
7-
case PENDING = 'pending';
8-
case APPROVED = 'approved';
9-
case SUSPENDED = 'suspended';
10-
case REJECTED = 'rejected';
10+
case Pending = 'pending';
11+
case Approved = 'approved';
12+
case Suspended = 'suspended';
13+
case Rejected = 'rejected';
1114

12-
public function label(): string
15+
public function getLabel(): string
1316
{
1417
return match ($this) {
15-
self::PENDING => 'Pending',
16-
self::APPROVED => 'Approved',
17-
self::SUSPENDED => 'Suspended',
18-
self::REJECTED => 'Rejected',
18+
self::Pending => 'Pending',
19+
self::Approved => 'Approved',
20+
self::Suspended => 'Suspended',
21+
self::Rejected => 'Rejected',
1922
};
2023
}
2124

22-
public function color(): string
25+
public function getColor(): string
2326
{
2427
return match ($this) {
25-
self::PENDING => 'warning',
26-
self::APPROVED => 'success',
27-
self::SUSPENDED => 'danger',
28-
self::REJECTED => 'danger',
28+
self::Pending => 'warning',
29+
self::Approved => 'success',
30+
self::Suspended => 'danger',
31+
self::Rejected => 'danger',
2932
};
3033
}
3134
}

app/Enums/OperatorType.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,36 @@
22

33
namespace App\Enums;
44

5-
enum OperatorType: string
5+
use Filament\Support\Contracts\HasColor;
6+
use Filament\Support\Contracts\HasIcon;
7+
use Filament\Support\Contracts\HasLabel;
8+
9+
enum OperatorType: string implements HasLabel, HasIcon, HasColor
610
{
7-
case HOTEL = 'hotel';
8-
case BUS = 'bus';
11+
case Hotel = 'hotel';
12+
case Bus = 'bus';
13+
14+
public function getLabel(): string
15+
{
16+
return match ($this) {
17+
self::Hotel => 'Hotel',
18+
self::Bus => 'Bus',
19+
};
20+
}
21+
22+
public function getIcon(): ?string
23+
{
24+
return match ($this) {
25+
self::Hotel => 'lucide-hotel',
26+
self::Bus => 'lucide-bus',
27+
};
28+
}
929

10-
public function label(): string
30+
public function getColor(): string|array|null
1131
{
1232
return match ($this) {
13-
self::HOTEL => 'Hotel',
14-
self::BUS => 'Bus',
33+
self::Hotel => 'primary',
34+
self::Bus => 'info',
1535
};
1636
}
1737
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Enums\Enums;
3+
namespace App\Enums;
44

55
use Filament\Support\Contracts\HasLabel;
66

app/Filament/Admin/Resources/Operators/Tables/OperatorsTable.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ public static function configure(Table $table): Table
3333
TextColumn::make('type')
3434
->badge()
3535
->color(fn (OperatorType $state): string => match ($state) {
36-
OperatorType::BUS => 'primary',
37-
OperatorType::HOTEL => 'success',
36+
OperatorType::Bus => 'primary',
37+
OperatorType::Hotel => 'success',
3838
})
3939
->formatStateUsing(fn (OperatorType $state): string => $state->label()),
4040

4141
TextColumn::make('status')
4242
->badge()
4343
->color(fn (OperatorStatus $state): string => match ($state) {
44-
OperatorStatus::APPROVED => 'success',
45-
OperatorStatus::PENDING => 'warning',
46-
OperatorStatus::SUSPENDED => 'danger',
47-
OperatorStatus::REJECTED => 'gray',
44+
OperatorStatus::Approved => 'success',
45+
OperatorStatus::Pending => 'warning',
46+
OperatorStatus::Suspended => 'danger',
47+
OperatorStatus::Rejected => 'gray',
4848
})
4949
->formatStateUsing(fn (OperatorStatus $state): string => $state->label()),
5050

@@ -79,7 +79,7 @@ public static function configure(Table $table): Table
7979
Action::make('approve')
8080
->icon('heroicon-o-check-circle')
8181
->color('success')
82-
->visible(fn (Operator $record): bool => $record->status === OperatorStatus::PENDING &&
82+
->visible(fn (Operator $record): bool => $record->status === OperatorStatus::Pending &&
8383
Auth::user()->roles()->whereHas('permissions', function (Builder $query): void {
8484
$query->where('name', 'approve_operator');
8585
})->exists(),
@@ -92,7 +92,7 @@ public static function configure(Table $table): Table
9292
])
9393
->action(function (Operator $record, array $data): void {
9494
$oldStatus = $record->status;
95-
$record->update(['status' => OperatorStatus::APPROVED]);
95+
$record->update(['status' => OperatorStatus::Approved]);
9696

9797
// Get all users associated with this operator
9898
$operatorUsers = $record->users;
@@ -118,7 +118,7 @@ public static function configure(Table $table): Table
118118
Action::make('suspend')
119119
->icon('heroicon-o-pause-circle')
120120
->color('warning')
121-
->visible(fn (Operator $record): bool => $record->status === OperatorStatus::APPROVED &&
121+
->visible(fn (Operator $record): bool => $record->status === OperatorStatus::Approved &&
122122
Auth::user()->roles()->whereHas('permissions', function (Builder $query): void {
123123
$query->where('name', 'approve_operator');
124124
})->exists(),
@@ -132,7 +132,7 @@ public static function configure(Table $table): Table
132132
])
133133
->action(function (Operator $record, array $data): void {
134134
$oldStatus = $record->status;
135-
$record->update(['status' => OperatorStatus::SUSPENDED]);
135+
$record->update(['status' => OperatorStatus::Suspended]);
136136

137137
// Get all users associated with this operator
138138
$operatorUsers = $record->users;
@@ -158,7 +158,7 @@ public static function configure(Table $table): Table
158158
Action::make('reject')
159159
->icon('heroicon-o-x-circle')
160160
->color('danger')
161-
->visible(fn (Operator $record): bool => $record->status === OperatorStatus::PENDING &&
161+
->visible(fn (Operator $record): bool => $record->status === OperatorStatus::Pending &&
162162
Auth::user()->roles()->whereHas('permissions', function (Builder $query): void {
163163
$query->where('name', 'approve_operator');
164164
})->exists(),
@@ -172,7 +172,7 @@ public static function configure(Table $table): Table
172172
])
173173
->action(function (Operator $record, array $data): void {
174174
$oldStatus = $record->status;
175-
$record->update(['status' => OperatorStatus::REJECTED]);
175+
$record->update(['status' => OperatorStatus::Rejected]);
176176

177177
// Get all users associated with this operator
178178
$operatorUsers = $record->users;

app/Filament/Operator/Pages/Tenancy/EditOperatorProfile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function form(Schema $schema): Schema
4646
->required()
4747
->disabled()
4848
->options([
49-
OperatorType::HOTEL->value => 'Hotel Operator',
50-
OperatorType::BUS->value => 'Bus Operator',
49+
OperatorType::Hotel->value => 'Hotel Operator',
50+
OperatorType::Bus->value => 'Bus Operator',
5151
])
5252
->helperText('The type of service you provide'),
5353

app/Filament/Operator/Pages/Tenancy/OperatorStatusPage.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ public function mount(): void
122122
public function getStatusHeading(): string
123123
{
124124
return match ($this->operator->status) {
125-
OperatorStatus::PENDING => '⏳ Registration Under Review',
126-
OperatorStatus::APPROVED => '✅ Operator Approved',
127-
OperatorStatus::SUSPENDED => '⚠️ Account Suspended',
128-
OperatorStatus::REJECTED => '❌ Registration Rejected',
125+
OperatorStatus::Pending => '⏳ Registration Under Review',
126+
OperatorStatus::Approved => '✅ Operator Approved',
127+
OperatorStatus::Suspended => '⚠️ Account Suspended',
128+
OperatorStatus::Rejected => '❌ Registration Rejected',
129129
};
130130
}
131131

132132
public function getStatusDescription(): string
133133
{
134134
return match ($this->operator->status) {
135-
OperatorStatus::PENDING => 'Your operator registration is currently being reviewed by our team. We will notify you via email once a decision has been made.',
136-
OperatorStatus::APPROVED => 'Congratulations! Your operator account has been approved and is fully active. You now have access to all operator features.',
137-
OperatorStatus::SUSPENDED => 'Your operator account has been temporarily suspended. Please contact support for assistance in resolving this issue.',
138-
OperatorStatus::REJECTED => 'Unfortunately, your operator registration could not be approved at this time. Please review the feedback and consider reapplying.',
135+
OperatorStatus::Pending => 'Your operator registration is currently being reviewed by our team. We will notify you via email once a decision has been made.',
136+
OperatorStatus::Approved => 'Congratulations! Your operator account has been approved and is fully active. You now have access to all operator features.',
137+
OperatorStatus::Suspended => 'Your operator account has been temporarily suspended. Please contact support for assistance in resolving this issue.',
138+
OperatorStatus::Rejected => 'Unfortunately, your operator registration could not be approved at this time. Please review the feedback and consider reapplying.',
139139
};
140140
}
141141

@@ -145,10 +145,10 @@ public function getStatusDescription(): string
145145
public function getStatusColor(): string
146146
{
147147
return match ($this->operator->status) {
148-
OperatorStatus::PENDING => 'warning',
149-
OperatorStatus::APPROVED => 'success',
150-
OperatorStatus::SUSPENDED => 'danger',
151-
OperatorStatus::REJECTED => 'danger',
148+
OperatorStatus::Pending => 'warning',
149+
OperatorStatus::Approved => 'success',
150+
OperatorStatus::Suspended => 'danger',
151+
OperatorStatus::Rejected => 'danger',
152152
};
153153
}
154154

@@ -158,23 +158,23 @@ public function getStatusColor(): string
158158
public function getNextSteps(): array
159159
{
160160
return match ($this->operator->status) {
161-
OperatorStatus::PENDING => [
161+
OperatorStatus::Pending => [
162162
'Check your email regularly for updates',
163163
'Ensure your contact information is up to date',
164164
'Be patient - review process typically takes 2-3 business days',
165165
],
166-
OperatorStatus::APPROVED => [
166+
OperatorStatus::Approved => [
167167
'Complete your operator profile',
168168
'Set up your booking settings',
169169
'Start managing your reservations',
170170
'Explore the operator dashboard features',
171171
],
172-
OperatorStatus::SUSPENDED => [
172+
OperatorStatus::Suspended => [
173173
'Contact support immediately',
174174
'Review our terms of service',
175175
'Prepare any required documentation',
176176
],
177-
OperatorStatus::REJECTED => [
177+
OperatorStatus::Rejected => [
178178
'Review the feedback provided',
179179
'Address any issues mentioned',
180180
'Consider submitting a new application',

0 commit comments

Comments
 (0)