-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewUser.php
34 lines (27 loc) · 882 Bytes
/
ViewUser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace ClarkWinkelmann\ShadowBan\Scope;
use Carbon\Carbon;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
class ViewUser
{
protected $settings;
public function __construct(SettingsRepositoryInterface $settings)
{
$this->settings = $settings;
}
public function __invoke(User $actor, Builder $query)
{
if (!$this->settings->get('clarkwinkelmann-shadow-ban.hideUsers') || $actor->can('shadowBan', User::class)) {
return;
}
$query->where(function (Builder $query) use ($actor) {
$query->whereNull('shadow_banned_until')
->orWhere('shadow_banned_until', '<', Carbon::now());
if (!$actor->isGuest()) {
$query->orWhere('users.id', '=', $actor->id);
}
});
}
}