Completed
Push — master ( cdad02...2b0328 )
by Elf
07:32
created

DataTable::staticColumn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 2
dl 0
loc 15
ccs 0
cts 8
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Support\Datatables\Services;
4
5
use App\Support\Datatables\Html\Builder as HtmlBuilder;
6
use Yajra\Datatables\Services\DataTable as BaseDataTable;
7
8
abstract class DataTable extends BaseDataTable
9
{
10
    /**
11
     * Get attributes for a "static" column that can not be
12
     * ordered, searched, nor exported.
13
     *
14
     * @param  string  $name
15
     * @param  array  $attributes
16
     * @return $this
17
     */
18
    protected function staticColumn($name, array $attributes = [])
19
    {
20
        return array_merge([
21
            'data' => $name,
22
            'name' => $name,
23
            'title' => $this->builder()->getQualifiedTitle($name),
24
            'defaultContent' => '',
25
            'render' => null,
26
            'orderable' => false,
27
            'searchable' => false,
28
            'exportable' => false,
29
            'printable' => true,
30
            'footer' => '',
31
        ], $attributes);
32
    }
33
34
    /**
35
     * Get filename for export.
36
     *
37
     * @return string
38
     */
39
    protected function filename()
40
    {
41
        return preg_replace('#datatable$#i', '', class_basename($this)).'-'.date('Ymdhis');
42
    }
43
44
    /**
45
     * Get default builder parameters.
46
     *
47
     * @return array
48
     */
49
    protected function getBuilderParameters()
50
    {
51
        return [
52
            'order' => [[0, 'desc']],
53
        ];
54
    }
55
}
56