Passed
Branch master (249862)
by Adam
07:51
created

FlagsGrid   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B buildGrid() 0 44 2
1
<?php
2
3
namespace Coyote\Http\Grids\Adm;
4
5
use Boduch\Grid\Decorators\DateTimeLocalized;
6
use Boduch\Grid\Decorators\StrLimit;
7
use Boduch\Grid\Decorators\Url;
8
use Boduch\Grid\Filters\FilterOperator;
9
use Boduch\Grid\Filters\Text;
10
use Coyote\Flag;
11
use Coyote\Services\Grid\Grid;
12
use Boduch\Grid\Order;
13
use Boduch\Grid\Row;
14
15
class FlagsGrid extends Grid
16
{
17
    public function buildGrid()
18
    {
19
        $this
20
            ->setDefaultOrder(new Order('id', 'desc'))
21
            ->addColumn('id', [
22
                'title' => 'ID',
23
                'sortable' => true
24
            ])
25
            ->addColumn('flag_type', [
26
                'placeholder' => '--',
27
                'title' => 'Typ'
28
            ])
29
            ->addColumn('user_name', [
30
                'title' => 'Nazwa użytkownika',
31
                'sortable' => true,
32
                'placeholder' => '--',
33
                'clickable' => function (Flag $row) {
34
                    return link_to_route('adm.users.save', $row->user_name, [$row->user_id]);
0 ignored issues
show
Bug introduced by
The property user_name does not seem to exist on Coyote\Flag. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
35
                },
36
                'filter' => new Text(['operator' => FilterOperator::OPERATOR_ILIKE])
37
            ])
38
            ->addColumn('url', [
39
                'title' => 'URL',
40
                'filter' => new Text(['operator' => FilterOperator::OPERATOR_ILIKE]),
41
                'decorators' => [new Url()]
42
            ])
43
            ->addColumn('text', [
44
                'title' => 'Opis',
45
                'decorators' => [new StrLimit()]
46
            ])
47
            ->addColumn('created_at', [
48
                'title' => 'Data utworzenia',
49
                'decorators' => [new DateTimeLocalized(auth()->user()->date_format)]
50
            ])
51
            ->addColumn('moderator_name', [
52
                'title' => 'Zamknięty przez',
53
                'clickable' => function (Flag $row) {
54
                    return link_to_route('adm.users.save', $row->moderator_name, [$row->moderator_id]);
0 ignored issues
show
Bug introduced by
The property moderator_name does not exist on Coyote\Flag. Did you mean moderator_id?
Loading history...
55
                },
56
                'placeholder' => '--'
57
            ])
58
            ->after(function (Row $row) {
59
                if (!empty($row->raw('deleted_at'))) {
60
                    $row->class = 'strikeout';
61
                }
62
            });
63
    }
64
}
65