Banned   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A listExtendQuery() 0 8 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