Completed
Pull Request — develop (#121)
by Neil
03:16
created

BaseDataTable::getAjax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
            ->ajax($this->getAjax());
44
    }
45
46
    /**
47
     * Get columns.
48
     *
49
     * @return array
50
     */
51
    abstract public function getColumns();
52
53
    /**
54
     * Get the query object to be processed by datatables.
55
     *
56
     * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
57
     */
58
    abstract public function query();
59
60
    /**
61
     * Get Builder Params
62
     *
63
     * @return array
64
     */
65
    protected function getBuilderParameters()
66
    {
67
        return [
68
            'dom' => "<'row'<'col-sm-3'l><'col-sm-6 text-center'B><'col-sm-3'f>>".
69
                "<'row'<'col-sm-12'tr>>".
70
                "<'row'<'col-sm-5'i><'col-sm-7'p>>",
71
            'lengthMenu' => [[25, 50, 100, -1], [25, 50, 100, "All"]],
72
            'buttons' => [
73
                'csv', 'excel', 'pdf', 'print', 'reset', 'reload',
74
            ],
75
            'autoWidth' => false,
76
        ];
77
    }
78
79
    /**
80
     * Get ajax url.
81
     *
82
     * @return string
83
     */
84
    public function getAjax()
85
    {
86
        return '';    
87
    }
88
89
}
90