Banned::listExtendQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php namespace VojtaSvoboda\UserBanned\Controllers;
2
3
use Auth;
4
use BackendMenu;
5
use Backend\Classes\Controller;
6
use RainLab\User\Controllers\Users;
7
8
class Banned extends Users
9
{
10
    public $implement = [
11
        'Backend.Behaviors.ListController',
12
    ];
13
14
    public $listConfig = 'config_list.yaml';
15
16
    public function __construct()
17
    {
18
        parent::__construct();
19
20
        BackendMenu::setContext('RainLab.User', 'user', 'banned');
21
    }
22
23
    public function listExtendQuery($query)
24
    {
25
        $throttleModel = Auth::createThrottleModel();
26
        $bannedCollection = $throttleModel->where('is_banned', true)->get()->map(function ($item) {
27
            return $item->user_id;
28
        });
29
        $query->whereIn('id', $bannedCollection);
30
    }
31
}
32