Skip to content

Commit 9133988

Browse files
committed
fix: (LAR-86) fixing phpstan error
1 parent 7cdf064 commit 9133988

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ final class ListUsers extends ListRecords
1515
public function getTabs() : array
1616
{
1717
return [
18-
__('global.all') => Tab::make(__('global.all')),
19-
__('global.banned') => Tab::make(__('global.banned'))
20-
->modifyQueryUsing(function ($query) {
21-
return $query->isBanned();
22-
}),
23-
__('global.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(function ($query) {
21+
return $query->isBanned();
22+
}),
23+
'unbanned' => Tab::make(__('global.unbanned'))
24+
->modifyQueryUsing(function ($query) {
25+
return $query->isNotBanned();
26+
}),
2727
];
2828
}
2929
}

app/Http/Middleware/CheckIfBanned.php

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

77
use Closure;
8+
use Carbon\Carbon;
89
use Illuminate\Http\Request;
910
use Illuminate\Support\Facades\Auth;
1011
use Symfony\Component\HttpFoundation\Response;
@@ -13,12 +14,16 @@ final class CheckIfBanned
1314
{
1415
public function handle(Request $request, Closure $next): Response
1516
{
16-
if (Auth::check() && Auth::user()->banned_at) {
17-
Auth::logout();
18-
19-
return redirect()->route('login')->withErrors([
20-
'email' => __('global.ban.message'),
21-
]);
17+
if (Auth::check()) {
18+
$user = Auth::user();
19+
20+
if ($user && $user->banned_at) {
21+
Auth::logout();
22+
23+
return redirect()->route('login')->withErrors([
24+
'email' => __('global.ban.message'),
25+
]);
26+
}
2227
}
2328

2429
return $next($request);

0 commit comments

Comments
 (0)