@@ -77,7 +77,7 @@ public function ban(
7777
7878 $ this ->bans ->push ($ ban );
7979
80- $ this ->ban_level = $ ban ->isActive ();
80+ $ this ->ban_level = $ ban ->isActive () ? $ ban -> level : null ;
8181 $ this ->save ();
8282
8383 return $ ban ;
@@ -96,23 +96,35 @@ public function unban(): static
9696 return $ this ;
9797 }
9898
99- public function isBanned (): bool
99+ public function isBanned (? int $ level = null ): bool
100100 {
101+ if ($ level ) {
102+ return $ this ->ban_level === $ level ;
103+ }
104+
101105 return $ this ->ban_level !== null ;
102106 }
103107
104- public function isNotBanned (): bool
108+ public function isNotBanned (? int $ level = null ): bool
105109 {
106- return ! $ this ->isBanned ();
110+ return ! $ this ->isBanned ($ level );
107111 }
108112
109- public function scopeBanned (Builder $ query ): Builder
113+ public function scopeBanned (Builder $ query, ? int $ level = null ): Builder
110114 {
115+ if ($ level ) {
116+ return $ query ->where ('ban_level ' , '= ' , $ level );
117+ }
118+
111119 return $ query ->where ('ban_level ' , '!= ' , null );
112120 }
113121
114- public function scopeNotBanned (Builder $ query ): Builder
122+ public function scopeNotBanned (Builder $ query, ? int $ level = null ): Builder
115123 {
124+ if ($ level ) {
125+ return $ query ->where ('ban_level ' , '!= ' , $ level );
126+ }
127+
116128 return $ query ->where ('ban_level ' , '= ' , null );
117129 }
118130}
0 commit comments