Completed
Push — master ( 188ffb...31684b )
by Maxime
02:48
created

UserDatatable   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 6 1
A applyFilters() 0 14 3
A filters() 0 10 1
1
<?php namespace Distilleries\Expendable\Http\Datatables\User;
2
3
use Distilleries\Expendable\Http\Datatables\BaseDatatable;
4
use Distilleries\Expendable\Helpers\StaticLabel;
5
use Distilleries\Expendable\Helpers\UserUtils;
6
use Distilleries\Expendable\Models\Role;
7
8
class UserDatatable extends BaseDatatable {
9
10
    public function build()
11
    {
12
        $this->add('id');
13
        $this->add('email');
14
        $this->addDefaultAction('expendable::admin.user.datatable.action');
15
    }
16
17
    public function applyFilters()
18
    {
19
        parent::applyFilters();
20
        if (UserUtils::isNotSuperAdmin())
21
        {
22
            $super_admin = Role::where('initials', '=', '@sa')->get()->last();
23
24
            if (!empty($super_admin))
25
            {
26
                $this->model = $this->model->where('role_id', '!=', $super_admin->id);
27
            }
28
        }
29
30
    }
31
32
    public function filters()
33
    {
34
        $this->form->add('status', 'choice', [
35
            'choices'     => StaticLabel::status(),
36
            'empty_value' => '-',
37
            'validation'  => 'required',
38
            'label'       => trans('expendable::datatable.status')
39
        ]);
40
41
    }
42
}