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

FileAssetsDataTable::ajax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
cc 1
eloc 4
nc 1
nop 0
rs 9.4285
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