Completed
Push — develop ( 6aff41...589f19 )
by Tony
03:10
created

BaseDataTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 47
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A html() 0 6 1
getColumns() 0 1 ?
query() 0 1 ?
A getBuilderParameters() 0 13 1
1
<?php
2
/**
3
 * BaseDataTable.php
4
 *
5
 * -Description-
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Tony Murray
23
 * @author     Tony Murray <[email protected]>
24
 */
25
26
namespace App\DataTables;
27
28
29
use Yajra\Datatables\Services\DataTable;
30
31
abstract class BaseDataTable extends DataTable
32
{
33
    /**
34
     * Optional method if you want to use html builder.
35
     *
36
     * @return \Yajra\Datatables\Html\Builder
37
     */
38
    public function html()
39
    {
40
        return $this->builder()
41
            ->columns($this->getColumns())
42
            ->parameters($this->getBuilderParameters());
43
    }
44
45
    /**
46
     * Get columns.
47
     *
48
     * @return array
49
     */
50
    abstract public function getColumns();
51
52
    /**
53
     * Get the query object to be processed by datatables.
54
     *
55
     * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
56
     */
57
    abstract public function query();
58
    
59
    /**
60
     * Get Builder Params
61
     *
62
     * @return array
63
     */
64
    protected function getBuilderParameters()
65
    {
66
        return [
67
            'dom' => "<'row'<'col-sm-3'l><'col-sm-6 text-center'B><'col-sm-3'f>>".
68
                "<'row'<'col-sm-12'tr>>".
69
                "<'row'<'col-sm-5'i><'col-sm-7'p>>",
70
            'lengthMenu' => [[25, 50, 100, -1], [25, 50, 100, "All"]],
71
            'buttons' => [
72
                'csv', 'excel', 'pdf', 'print', 'reset', 'reload',
73
            ],
74
            'autoWidth' => false,
75
        ];
76
    }
77
}
78