Completed
Push — master ( ea6a29...8e9f97 )
by Brandon
05:31
created

UsersDataTable::html()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 12
cp 0
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\DataTables;
4
5
use App\User;
6
use Yajra\Datatables\Services\DataTable;
7
8
class UsersDataTable extends DataTable
9
{
10
    /**
11
     * Build DataTable class.
12
     *
13
     * @return \Yajra\Datatables\Engines\BaseEngine
14
     */
15
    public function dataTable()
16
    {
17
        return $this->datatables
18
            ->eloquent($this->query())
19
            ->addColumn('action', 'users.action');
20
    }
21
22
    /**
23
     * Get the query object to be processed by dataTables.
24
     *
25
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection
26
     */
27
    public function query()
28
    {
29
        $query = User::query();
30
31
        return $this->applyScopes($query);
32
    }
33
34
    /**
35
     * Optional method if you want to use html builder.
36
     *
37
     * @return \Yajra\Datatables\Html\Builder
38
     */
39
    public function html()
40
    {
41
        return $this->builder()
42
                    ->columns($this->getColumns())
43
                    //->minifiedAjax('')
44
                    //->addAction(['width' => '160px'])
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
                    ->parameters([
46
                        'dom'     => 'Bfrtip',
47
                        //'order'   => [[0, 'desc']],
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
                        'buttons' => [
49
                            'create',
50
                            'export',
51
                            'print',
52
                            'reset',
53
                            'reload',
54
                        ],
55
                    ]);
56
    }
57
58
    /**
59
     * Get columns.
60
     *
61
     * @return array
62
     */
63
    protected function getColumns()
64
    {
65
        return [
66
            'id',
67
            'name',
68
            'email',
69
            'created_at',
70
            'updated_at',
71
        ];
72
    }
73
74
    /**
75
     * Get filename for export.
76
     *
77
     * @return string
78
     */
79
    protected function filename()
80
    {
81
        return 'users_' . time();
82
    }
83
}
84