PagesDataTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A query() 0 7 1
A getColumns() 0 18 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Pages\DataTables\Managerarea;
6
7
use Cortex\Pages\Models\Page;
8
use Cortex\Foundation\DataTables\AbstractDataTable;
9
use Cortex\Pages\Transformers\Managerarea\PageTransformer;
10
11
class PagesDataTable extends AbstractDataTable
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    protected $model = Page::class;
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected $transformer = PageTransformer::class;
22
23
    /**
24
     * Get the query object to be processed by dataTables.
25
     *
26
     * @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...
27
     */
28
    public function query()
29
    {
30
        $locale = app()->getLocale();
31
        $query = app($this->model)->query()->orderBy('sort_order', 'ASC')->orderBy("title->\${$locale}", 'ASC');
32
33
        return $this->applyScopes($query);
34
    }
35
36
    /**
37
     * Get columns.
38
     *
39
     * @return array
40
     */
41
    protected function getColumns(): array
42
    {
43
        $link = config('cortex.foundation.route.locale_prefix')
44
            ? '"<a href=\""+routes.route(\'managerarea.pages.edit\', {page: full.id, locale: \''.$this->request->segment(1).'\'})+"\">"+data+"</a>"'
45
            : '"<a href=\""+routes.route(\'managerarea.pages.edit\', {page: full.id})+"\">"+data+"</a>"';
46
47
        return [
48
            'title' => ['title' => trans('cortex/pages::common.title'), 'render' => $link.'+(full.is_active ? " <i class=\"text-success fa fa-check\"></i>" : " <i class=\"text-danger fa fa-close\"></i>")', 'responsivePriority' => 0],
49
            'uri' => ['title' => trans('cortex/pages::common.uri')],
50
            'domain' => ['title' => trans('cortex/pages::common.domain'), 'visible' => false],
51
            'route' => ['title' => trans('cortex/pages::common.route')],
52
            'view' => ['title' => trans('cortex/pages::common.view'), 'visible' => false],
53
            'middleware' => ['title' => trans('cortex/pages::common.middleware'), 'visible' => false],
54
            'sort_order' => ['title' => trans('cortex/pages::common.sort_order'), 'visible' => false],
55
            'created_at' => ['title' => trans('cortex/pages::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
56
            'updated_at' => ['title' => trans('cortex/pages::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
57
        ];
58
    }
59
}
60