Completed
Push — develop ( 5abd4c...dae2aa )
by Abdelrahman
09:07
created

RolesDataTable::ajax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Auth\DataTables\Adminarea;
6
7
use Cortex\Auth\Models\Role;
8
use Cortex\Foundation\DataTables\AbstractDataTable;
9
10
class RolesDataTable extends AbstractDataTable
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected $model = Role::class;
16
17
    /**
18
     * Display ajax response.
19
     *
20
     * @return \Illuminate\Http\JsonResponse
21
     */
22
    public function ajax()
23
    {
24
        return datatables($this->query())
25
            ->orderColumn('title', 'title->"$.'.app()->getLocale().'" $1')
26
            ->make(true);
27
    }
28
29
    /**
30
     * Get columns.
31
     *
32
     * @return array
33
     */
34
    protected function getColumns(): array
35
    {
36
        $link = config('cortex.foundation.route.locale_prefix')
37
            ? '"<a href=\""+routes.route(\'adminarea.roles.edit\', {role: 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 146 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...
38
            : '"<a href=\""+routes.route(\'adminarea.roles.edit\', {role: full.id})+"\">"+data+"</a>"';
39
40
        return [
41
            'title' => ['title' => trans('cortex/auth::common.title'), 'render' => $link, 'responsivePriority' => 0],
42
            'name' => ['title' => trans('cortex/auth::common.name')],
43
            'created_at' => ['title' => trans('cortex/auth::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 132 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...
44
            'updated_at' => ['title' => trans('cortex/auth::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 132 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...
45
        ];
46
    }
47
}
48