AttributesDataTable::getColumns()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Attributes\DataTables\Adminarea;
6
7
use Cortex\Attributes\Models\Attribute;
8
use Cortex\Foundation\DataTables\AbstractDataTable;
9
use Cortex\Attributes\Transformers\Adminarea\AttributeTransformer;
10
11
class AttributesDataTable extends AbstractDataTable
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    protected $model = Attribute::class;
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected $transformer = AttributeTransformer::class;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected $order = [
27
        [1, 'asc'],
28
        [0, 'asc'],
29
    ];
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected $builderParameters = [
35
        'rowGroup' => '{
36
            dataSrc: \'group\'
37
        }',
38
    ];
39
40
    /**
41
     * Get columns.
42
     *
43
     * @return array
44
     */
45
    protected function getColumns(): array
46
    {
47
        $link = config('cortex.foundation.route.locale_prefix')
48
            ? '"<a href=\""+routes.route(\'adminarea.attributes.edit\', {attribute: full.id, locale: \''.$this->request->segment(1).'\'})+"\">"+data+"</a>"'
49
            : '"<a href=\""+routes.route(\'adminarea.attributes.edit\', {attribute: full.id})+"\">"+data+"</a>"';
50
51
        return [
52
            'name' => ['title' => trans('cortex/attributes::common.name'), 'render' => $link, 'responsivePriority' => 0],
53
            'type' => ['title' => trans('cortex/attributes::common.type'), 'render' => 'Lang.trans(\'cortex/attributes::common.\'+data)'],
54
            'group' => ['title' => trans('cortex/attributes::common.group'), 'visible' => false],
55
            'is_collection' => ['title' => trans('cortex/attributes::common.is_collection')],
56
            'is_required' => ['title' => trans('cortex/attributes::common.is_required')],
57
            'created_at' => ['title' => trans('cortex/attributes::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
58
            'updated_at' => ['title' => trans('cortex/attributes::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
59
        ];
60
    }
61
}
62