|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Coyote\Http\Grids\Adm; |
|
4
|
|
|
|
|
5
|
|
|
use Boduch\Grid\Filters\FilterOperator; |
|
6
|
|
|
use Boduch\Grid\Filters\Select; |
|
7
|
|
|
use Boduch\Grid\Filters\Text; |
|
8
|
|
|
use Coyote\Services\Grid\Components\FirewallButton; |
|
9
|
|
|
use Coyote\Services\Grid\Grid; |
|
10
|
|
|
use Boduch\Grid\Decorators\Boolean; |
|
11
|
|
|
use Boduch\Grid\Decorators\Ip; |
|
12
|
|
|
use Boduch\Grid\Order; |
|
13
|
|
|
use Boduch\Grid\Components\EditButton; |
|
14
|
|
|
use Coyote\User; |
|
15
|
|
|
|
|
16
|
|
|
class UsersGrid extends Grid |
|
17
|
|
|
{ |
|
18
|
|
|
const YES = 1; |
|
19
|
|
|
const NO = 0; |
|
20
|
|
|
|
|
21
|
|
|
public function buildGrid() |
|
22
|
|
|
{ |
|
23
|
|
|
$booleanOptions = [self::YES => 'Tak', self::NO => 'Nie']; |
|
24
|
|
|
|
|
25
|
|
|
$this |
|
26
|
|
|
->setDefaultOrder(new Order('id', 'desc')) |
|
27
|
|
|
->addColumn('id', [ |
|
28
|
|
|
'title' => 'ID', |
|
29
|
|
|
'sortable' => true |
|
30
|
|
|
]) |
|
31
|
|
|
->addColumn('name', [ |
|
32
|
|
|
'title' => 'Nazwa użytkownika', |
|
33
|
|
|
'sortable' => true, |
|
34
|
|
|
'clickable' => function (User $user) { |
|
35
|
|
|
return link_to_route('adm.users.save', $user->name, [$user->id]); |
|
36
|
|
|
}, |
|
37
|
|
|
'filter' => new Text(['operator' => FilterOperator::OPERATOR_ILIKE]) |
|
38
|
|
|
]) |
|
39
|
|
|
->addColumn('email', [ |
|
40
|
|
|
'title' => 'E-mail', |
|
41
|
|
|
'filter' => new Text(['operator' => FilterOperator::OPERATOR_ILIKE]) |
|
42
|
|
|
]) |
|
43
|
|
|
->addColumn('created_at', [ |
|
44
|
|
|
'title' => 'Data rejestracji' |
|
45
|
|
|
]) |
|
46
|
|
|
->addColumn('visited_at', [ |
|
47
|
|
|
'title' => 'Data ost. wizyty', |
|
48
|
|
|
'sortable' => true |
|
49
|
|
|
]) |
|
50
|
|
|
->addColumn('is_active', [ |
|
51
|
|
|
'title' => 'Aktywny', |
|
52
|
|
|
'decorators' => [new Boolean()], |
|
53
|
|
|
'filter' => new Select(['options' => $booleanOptions]) |
|
54
|
|
|
]) |
|
55
|
|
|
->addColumn('is_blocked', [ |
|
56
|
|
|
'title' => 'Zablokowany', |
|
57
|
|
|
'decorators' => [new Boolean()], |
|
58
|
|
|
'filter' => new Select(['options' => $booleanOptions]) |
|
59
|
|
|
]) |
|
60
|
|
|
->addColumn('ip', [ |
|
61
|
|
|
'title' => 'IP', |
|
62
|
|
|
'decorators' => [new Ip()], |
|
63
|
|
|
'filter' => new Text(['operator' => FilterOperator::OPERATOR_ILIKE]) |
|
64
|
|
|
]) |
|
65
|
|
|
->addColumn('reputation', [ |
|
66
|
|
|
'title' => 'Reputacja', |
|
67
|
|
|
'sortable' => true |
|
68
|
|
|
]) |
|
69
|
|
|
->addRowAction(new FirewallButton(function (User $user) { |
|
70
|
|
|
return route('adm.firewall.save') . '?' . http_build_query(['user' => $user->id, 'ip' => $user->ip]); |
|
71
|
|
|
})) |
|
72
|
|
|
->addRowAction(new EditButton(function (User $user) { |
|
73
|
|
|
return route('adm.users.save', [$user->id]); |
|
74
|
|
|
})); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|