DatatableStateTrait::getIndexDatatable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 2
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Distilleries\DatatableBuilder\States;
4
5
trait DatatableStateTrait
6
{
7
    /**
8
     * Datatable (injected by the constructor).
9
     *
10
     * @var \Distilleries\DatatableBuilder\EloquentDatatable $datatable
11
     */
12
    protected $datatable;
13
14
    /**
15
     * Model (injected by the contructor).
16
     *
17
     * @var \Illuminate\Database\Eloquent\Model $model
18
     */
19
    protected $model;
20
21
    /**
22
     * View to display datatable.
23
     *
24
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
25
     */
26 4
    public function getIndexDatatable()
27
    {
28 4
        $this->datatable->build();
29 4
        $datatable = $this->datatable->generateHtmlRender();
30
31 4
        return view('datatable-builder::form.state.datatable')->with([
32 4
            'datatable' => $datatable,
33
        ]);
34
    }
35
36
    /**
37
     * Return generated datatable.
38
     *
39
     * @return mixed
40
     */
41 2
    public function getDatatable()
42
    {
43 2
        $this->datatable->setModel($this->model);
44 2
        $this->datatable->build();
45
46 2
        return $this->datatable->generateColomns();
47
    }
48
}
49