Completed
Push — master ( cad27a...4c05a1 )
by Elf
05:17
created

DataTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 48
ccs 0
cts 25
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A staticColumn() 0 15 1
A filename() 0 4 1
A getBuilderParameters() 0 6 1
1
<?php
2
3
namespace ElfSundae\Laravel\Datatables\Services;
4
5
use Yajra\Datatables\Services\DataTable as BaseDataTable;
6
7
abstract class DataTable extends BaseDataTable
8
{
9
    /**
10
     * Get attributes for a "static" column that can not be
11
     * ordered, searched, or exported.
12
     *
13
     * @param  string  $name
14
     * @param  array  $attributes
15
     * @return $this
16
     */
17
    protected function staticColumn($name, array $attributes = [])
18
    {
19
        return array_merge([
20
            'data' => $name,
21
            'name' => $name,
22
            'title' => $this->html()->getQualifiedTitle($name),
23
            'defaultContent' => '',
24
            'render' => null,
25
            'orderable' => false,
26
            'searchable' => false,
27
            'exportable' => false,
28
            'printable' => true,
29
            'footer' => '',
30
        ], $attributes);
31
    }
32
33
    /**
34
     * Get filename for export.
35
     *
36
     * @return string
37
     */
38
    protected function filename()
39
    {
40
        return preg_replace('#datatable$#i', '', class_basename($this)).'-'.date('YmdHis');
41
    }
42
43
    /**
44
     * Get default builder parameters.
45
     *
46
     * @return array
47
     */
48
    protected function getBuilderParameters()
49
    {
50
        return [
51
            'order' => [[0, 'desc']],
52
        ];
53
    }
54
}
55