Completed
Push — develop ( e16864...bade13 )
by Abdelrahman
09:13
created

AbilitiesDataTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ajax() 0 9 1
A getColumns() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Fort\DataTables\Backend;
6
7
use Cortex\Fort\Models\Ability;
8
use Cortex\Foundation\DataTables\AbstractDataTable;
9
use Cortex\Fort\Transformers\Backend\AbilityTransformer;
10
11
class AbilitiesDataTable extends AbstractDataTable
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    protected $model = Ability::class;
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected $transformer = AbilityTransformer::class;
22
23
    /**
24
     * Display ajax response.
25
     *
26
     * @return \Illuminate\Http\JsonResponse
27
     */
28
    public function ajax()
29
    {
30
        return $this->datatables
31
            ->eloquent($this->query())
32
            ->setTransformer(new $this->transformer)
33
            ->orderColumn('name', 'name->"$.'.app()->getLocale().'" $1')
34
            ->orderColumn('slug', 'action $1')
35
            ->make(true);
36
    }
37
38
    /**
39
     * Get columns.
40
     *
41
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,array>.

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...
42
     */
43
    protected function getColumns()
44
    {
45
        return [
46
            'name' => ['title' => trans('cortex/fort::common.name'), 'render' => '"<a href=\""+routes.route(\'backend.abilities.edit\', {ability: full.id})+"\">"+data+"</a>"', 'responsivePriority' => 0],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 203 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...
47
            'slug' => ['title' => trans('cortex/fort::common.slug')],
48
            'policy' => ['title' => trans('cortex/fort::common.policy')],
49
            'created_at' => ['title' => trans('cortex/fort::common.created_at'), 'width' => '15%', 'render' => "moment(data).format('MMM Do, YYYY')"],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 150 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...
50
            'updated_at' => ['title' => trans('cortex/fort::common.updated_at'), 'width' => '15%', 'render' => "moment(data).format('MMM Do, YYYY')"],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 150 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...
51
        ];
52
    }
53
}
54