Skip to content

Commit 0c221dc

Browse files
committed
fix(pint): (LAR-86) fixing laravel pint format
1 parent 02b039b commit 0c221dc

40 files changed

+308
-318
lines changed

app/Actions/Article/CreateArticleAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ public function execute(CreateArticleData $articleData): Article
3737

3838
return $article;
3939
}
40-
}
40+
}

app/Actions/User/BanUserAction.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Actions\User;
46

5-
use App\Models\User;
67
use App\Events\UserBannedEvent;
78
use App\Exceptions\CannotBanAdminException;
89
use App\Exceptions\UserAlreadyBannedException;
10+
use App\Models\User;
911

1012
final class BanUserAction
1113
{
@@ -14,16 +16,16 @@ public function execute(User $user, string $reason): void
1416
if ($user->hasRole('admin')) {
1517
throw new CannotBanAdminException;
1618
}
17-
18-
if($user->banned_at !== null) {
19+
20+
if ($user->banned_at !== null) {
1921
throw new UserAlreadyBannedException;
2022
}
2123

2224
$user->update([
23-
'banned_at' => now(),
24-
'banned_reason' => $reason
25+
'banned_at' => now(),
26+
'banned_reason' => $reason,
2527
]);
2628

2729
event(new UserBannedEvent($user));
2830
}
29-
}
31+
}

app/Actions/User/UnBanUserAction.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Actions\User;
46

5-
use App\Models\User;
67
use App\Events\UserUnbannedEvent;
8+
use App\Models\User;
79

810
final class UnBanUserAction
911
{
10-
public function execute(User $user) : void
12+
public function execute(User $user): void
1113
{
1214
$user->update([
1315
'banned_at' => null,
14-
'banned_reason' => null
16+
'banned_reason' => null,
1517
]);
16-
18+
1719
event(new UserUnbannedEvent($user));
1820
}
19-
}
21+
}

app/Events/UserBannedEvent.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
namespace App\Events;
66

77
use App\Models\User;
8-
use Illuminate\Broadcasting\Channel;
98
use Illuminate\Broadcasting\InteractsWithSockets;
10-
use Illuminate\Broadcasting\PresenceChannel;
11-
use Illuminate\Broadcasting\PrivateChannel;
12-
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
139
use Illuminate\Foundation\Events\Dispatchable;
1410
use Illuminate\Queue\SerializesModels;
1511

1612
final class UserBannedEvent
1713
{
1814
use Dispatchable, InteractsWithSockets, SerializesModels;
1915

20-
public function __construct(public User $user){}
21-
}
16+
public function __construct(public User $user) {}
17+
}

app/Events/UserUnbannedEvent.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
namespace App\Events;
66

77
use App\Models\User;
8-
use Illuminate\Broadcasting\Channel;
9-
use Illuminate\Queue\SerializesModels;
10-
use Illuminate\Broadcasting\PrivateChannel;
11-
use Illuminate\Broadcasting\PresenceChannel;
12-
use Illuminate\Foundation\Events\Dispatchable;
138
use Illuminate\Broadcasting\InteractsWithSockets;
14-
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
9+
use Illuminate\Foundation\Events\Dispatchable;
10+
use Illuminate\Queue\SerializesModels;
1511

1612
final class UserUnbannedEvent
1713
{
1814
use Dispatchable, InteractsWithSockets, SerializesModels;
1915

20-
public function __construct(public User $user){}
21-
}
16+
public function __construct(public User $user) {}
17+
}

app/Exceptions/CannotAddChannelToChild.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ public static function childChannelCannotBeParent(Channel $channel): self
1313
{
1414
return new self("Le channel [{$channel->name} ne peut pas être un channel parent.]");
1515
}
16-
}
16+
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Exceptions;
46

57
use Exception;
68

79
/**
810
* @property string $message
911
*/
10-
class CannotBanAdminException extends Exception
12+
final class CannotBanAdminException extends Exception
1113
{
1214
// @phpstan-ignore-next-line
13-
protected $message = "Impossible de bannir un administrateur.";
14-
}
15+
protected $message = 'Impossible de bannir un administrateur.';
16+
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Exceptions;
46

57
use Exception;
68

79
/**
810
* @property string $message
911
*/
10-
class UserAlreadyBannedException extends Exception
12+
final class UserAlreadyBannedException extends Exception
1113
{
1214
// @phpstan-ignore-next-line
13-
protected $message = "Impossible de bannir cet utilisateur car il est déjà banni.";
14-
}
15+
protected $message = 'Impossible de bannir cet utilisateur car il est déjà banni.';
16+
}

app/Filament/Resources/UserResource.php

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44

55
namespace App\Filament\Resources;
66

7-
use Carbon\Carbon;
8-
use App\Models\User;
9-
use Filament\Tables;
10-
use Filament\Tables\Table;
11-
use App\Events\UserBannedEvent;
12-
use Filament\Resources\Resource;
13-
use App\Events\UserUnbannedEvent;
147
use App\Actions\User\BanUserAction;
15-
use Illuminate\Support\Facades\Gate;
168
use App\Actions\User\UnBanUserAction;
17-
use Filament\Forms\Components\TextInput;
18-
use Filament\Notifications\Notification;
19-
use Illuminate\Database\Eloquent\Builder;
209
use App\Filament\Resources\UserResource\Pages;
10+
use App\Models\User;
2111
use Awcodes\FilamentBadgeableColumn\Components\Badge;
2212
use Awcodes\FilamentBadgeableColumn\Components\BadgeableColumn;
13+
use Filament\Forms\Components\TextInput;
14+
use Filament\Notifications\Notification;
15+
use Filament\Resources\Resource;
16+
use Filament\Tables;
17+
use Filament\Tables\Table;
18+
use Illuminate\Database\Eloquent\Builder;
19+
use Illuminate\Support\Facades\Gate;
2320

2421
final class UserResource extends Resource
2522
{
@@ -72,51 +69,51 @@ public static function table(Table $table): Table
7269
->nullable(),
7370
])
7471
->actions([
75-
Tables\Actions\Action::make('ban')
76-
->label(__('actions.ban'))
77-
->icon('untitledui-archive')
78-
->color('warning')
79-
->visible(fn ($record) => $record->banned_at == null)
80-
->modalHeading(__('user.ban.heading'))
81-
->modalDescription(__('user.ban.description'))
82-
->authorize(fn () => Gate::allows('ban', User::class))
83-
->form([
84-
85-
TextInput::make('banned_reason')
86-
->label(__('user.ban.reason'))
87-
->required(),
88-
])
89-
->action(function (User $record, array $data) {
90-
app(BanUserAction::class)->execute($record, $data['banned_reason']);
72+
Tables\Actions\Action::make('ban')
73+
->label(__('actions.ban'))
74+
->icon('untitledui-archive')
75+
->color('warning')
76+
->visible(fn ($record) => $record->banned_at == null)
77+
->modalHeading(__('user.ban.heading'))
78+
->modalDescription(__('user.ban.description'))
79+
->authorize(fn () => Gate::allows('ban', User::class))
80+
->form([
81+
82+
TextInput::make('banned_reason')
83+
->label(__('user.ban.reason'))
84+
->required(),
85+
])
86+
->action(function (User $record, array $data): void {
87+
app(BanUserAction::class)->execute($record, $data['banned_reason']);
88+
89+
Notification::make()
90+
->success()
91+
->duration(5000)
92+
->title(__('notifications.user.banned_title'))
93+
->body(__('notifications.user.banned_body'))
94+
->send();
95+
})
96+
->requiresConfirmation(),
97+
98+
Tables\Actions\Action::make('unban')
99+
->label(__('actions.unban'))
100+
->icon('heroicon-o-check-circle')
101+
->color('success')
102+
->visible(fn ($record) => $record->banned_at !== null)
103+
->authorize(fn () => Gate::allows('unban', User::class))
104+
->action(function (User $record): void {
105+
app(UnBanUserAction::class)->execute($record);
106+
107+
Notification::make()
108+
->success()
109+
->title(__('notifications.user.unbanned_title'))
110+
->duration(5000)
111+
->body(__('notifications.user.unbanned_body'))
112+
->send();
113+
})
114+
->requiresConfirmation(),
91115

92-
Notification::make()
93-
->success()
94-
->duration(5000)
95-
->title(__('notifications.user.banned_title'))
96-
->body(__('notifications.user.banned_body'))
97-
->send();
98-
})
99-
->requiresConfirmation(),
100-
101-
Tables\Actions\Action::make('unban')
102-
->label(__('actions.unban'))
103-
->icon('heroicon-o-check-circle')
104-
->color('success')
105-
->visible(fn ($record) => $record->banned_at !== null)
106-
->authorize(fn () => Gate::allows('unban', User::class))
107-
->action(function (User $record) {
108-
app(UnBanUserAction::class)->execute($record);
109-
110-
Notification::make()
111-
->success()
112-
->title(__('notifications.user.unbanned_title'))
113-
->duration(5000)
114-
->body(__('notifications.user.unbanned_body'))
115-
->send();
116-
})
117-
->requiresConfirmation(),
118-
119-
Tables\Actions\DeleteAction::make(),
116+
Tables\Actions\DeleteAction::make(),
120117
])
121118
->bulkActions([
122119
Tables\Actions\DeleteBulkAction::make(),
@@ -129,4 +126,4 @@ public static function getPages(): array
129126
'index' => Pages\ListUsers::route('/'),
130127
];
131128
}
132-
}
129+
}

app/Filament/Resources/UserResource/Pages/ListUsers.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,22 @@
44

55
namespace App\Filament\Resources\UserResource\Pages;
66

7-
use Filament\Resources\Components\Tab;
87
use App\Filament\Resources\UserResource;
8+
use Filament\Resources\Components\Tab;
99
use Filament\Resources\Pages\ListRecords;
1010

1111
final class ListUsers extends ListRecords
1212
{
1313
protected static string $resource = UserResource::class;
14-
15-
public function getTabs() : array
14+
15+
public function getTabs(): array
1616
{
1717
return [
18-
'all' => Tab::make(__('global.all')),
19-
'banned' => Tab::make(__('global.banned'))
20-
->modifyQueryUsing(function ($query) {
21-
return $query->isBanned();
22-
}),
23-
'unbanned' => Tab::make(__('global.unbanned'))
24-
->modifyQueryUsing(function ($query) {
25-
return $query->isNotBanned();
26-
}),
18+
'all' => Tab::make(__('global.all')),
19+
'banned' => Tab::make(__('global.banned'))
20+
->modifyQueryUsing(fn ($query) => $query->isBanned()),
21+
'unbanned' => Tab::make(__('global.unbanned'))
22+
->modifyQueryUsing(fn ($query) => $query->isNotBanned()),
2723
];
2824
}
29-
}
25+
}

app/Http/Middleware/CheckIfBanned.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace App\Http\Middleware;
66

77
use Closure;
8-
use Carbon\Carbon;
98
use Illuminate\Http\Request;
109
use Illuminate\Support\Facades\Auth;
1110
use Symfony\Component\HttpFoundation\Response;
@@ -17,12 +16,12 @@ public function handle(Request $request, Closure $next): Response
1716
// @phpstan-ignore-next-line
1817
if (Auth::check() && Auth::user()->banned_at) {
1918
Auth::logout();
20-
19+
2120
return redirect()->route('login')->withErrors([
2221
'email' => __('user.ban.message'),
2322
]);
2423
}
25-
24+
2625
return $next($request);
2726
}
28-
}
27+
}

app/Jobs/SendBanEmailJob.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44

55
namespace App\Jobs;
66

7-
use App\Models\User;
87
use App\Mail\UserBannedEMail;
8+
use App\Models\User;
99
use Illuminate\Bus\Queueable;
10-
use Illuminate\Support\Facades\Mail;
11-
use Illuminate\Queue\SerializesModels;
12-
use Illuminate\Queue\InteractsWithQueue;
1310
use Illuminate\Contracts\Queue\ShouldQueue;
1411
use Illuminate\Foundation\Bus\Dispatchable;
15-
use Illuminate\Contracts\Queue\ShouldBeUnique;
12+
use Illuminate\Queue\InteractsWithQueue;
13+
use Illuminate\Queue\SerializesModels;
14+
use Illuminate\Support\Facades\Mail;
1615

1716
final class SendBanEmailJob implements ShouldQueue
1817
{
1918
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2019

21-
public function __construct(public User $user){}
20+
public function __construct(public User $user) {}
2221

2322
public function handle(): void
2423
{
2524
Mail::to($this->user->email)->send(new UserBannedEMail($this->user));
2625
}
27-
}
26+
}

0 commit comments

Comments
 (0)