Completed
Push — master ( 7a1e6c...8794c3 )
by Arjay
11:28
created

FileAssetsDataTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ajax() 0 6 1
A query() 0 9 1
1
<?php
2
3
namespace Yajra\CMS\DataTables;
4
5
use Yajra\CMS\Entities\FileAsset;
6
use Yajra\Datatables\Services\DataTable;
7
8
class FileAssetsDataTable extends DataTable
9
{
10
    /**
11
     * Display ajax response.
12
     *
13
     * @return \Illuminate\Http\JsonResponse
14
     */
15
    public function ajax()
16
    {
17
        return $this->datatables
18
            ->eloquent($this->query())
19
            ->make(true);
20
    }
21
22
    /**
23
     * Get the query object to be processed by datatables.
24
     *
25
     * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
26
     */
27
    public function query()
28
    {
29
        $assets = FileAsset::select()
30
                           ->where('category', config('asset.default'))
31
                           ->where('type', $this->request()->get('type'))
32
                           ->orderBy('name', 'asc');
33
34
        return $this->applyScopes($assets);
35
    }
36
}
37