File tree Expand file tree Collapse file tree 2 files changed +20
-15
lines changed
Filament/Resources/UserResource/Pages Expand file tree Collapse file tree 2 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ final class ListUsers extends ListRecords
15
15
public function getTabs () : array
16
16
{
17
17
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
+ }),
27
27
];
28
28
}
29
29
}
Original file line number Diff line number Diff line change 5
5
namespace App \Http \Middleware ;
6
6
7
7
use Closure ;
8
+ use Carbon \Carbon ;
8
9
use Illuminate \Http \Request ;
9
10
use Illuminate \Support \Facades \Auth ;
10
11
use Symfony \Component \HttpFoundation \Response ;
@@ -13,12 +14,16 @@ final class CheckIfBanned
13
14
{
14
15
public function handle (Request $ request , Closure $ next ): Response
15
16
{
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
+ }
22
27
}
23
28
24
29
return $ next ($ request );
You can’t perform that action at this time.
0 commit comments