Completed
Push — develop ( dbe2eb...04ef1b )
by Abdelrahman
03:40 queued 22s
created

AttributesDataTable::ajax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
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 $builderParameters = [
27
        'rowGroup' => '{
28
            dataSrc: \'group\'
29
        }',
30
    ];
31
32
    /**
33
     * Get the query object to be processed by dataTables.
34
     *
35
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use \Illuminate\Database\Que...tabase\Eloquent\Builder.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
36
     */
37
    public function query()
38
    {
39
        $locale = app()->getLocale();
40
        $query = app($this->model)->query()->orderBy('group', 'ASC')->orderBy('sort_order', 'ASC')->orderBy("name->\${$locale}", 'ASC');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 136 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
41
42
        return $this->applyScopes($query);
43
    }
44
45
    /**
46
     * Get columns.
47
     *
48
     * @return array
49
     */
50
    protected function getColumns(): array
51
    {
52
        $link = config('cortex.foundation.route.locale_prefix')
53
            ? '"<a href=\""+routes.route(\'adminarea.attributes.edit\', {attribute: full.id, locale: \''.$this->request->segment(1).'\'})+"\">"+data+"</a>"'
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 156 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
54
            : '"<a href=\""+routes.route(\'adminarea.attributes.edit\', {attribute: full.id})+"\">"+data+"</a>"';
55
56
        return [
57
            'name' => ['title' => trans('cortex/attributes::common.name'), 'render' => $link, 'responsivePriority' => 0],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
58
            'type' => ['title' => trans('cortex/attributes::common.type'), 'render' => 'Lang.trans(\'cortex/attributes::common.\'+data)'],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
59
            'group' => ['title' => trans('cortex/attributes::common.group'), 'visible' => false],
60
            'is_collection' => ['title' => trans('cortex/attributes::common.is_collection')],
61
            'is_required' => ['title' => trans('cortex/attributes::common.is_required')],
62
            'created_at' => ['title' => trans('cortex/attributes::common.created_at'), 'render' => "moment(data).format('MMM Do, YYYY')"],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
63
            'updated_at' => ['title' => trans('cortex/attributes::common.updated_at'), 'render' => "moment(data).format('MMM Do, YYYY')"],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
64
        ];
65
    }
66
}
67