1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yajra\CMS\DataTables; |
4
|
|
|
|
5
|
|
|
use Yajra\Acl\Models\Role; |
6
|
|
|
use Yajra\Datatables\Services\DataTable; |
7
|
|
|
|
8
|
|
|
class RolesDataTable extends DataTable |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @return \Illuminate\Http\JsonResponse |
12
|
|
|
*/ |
13
|
|
|
public function ajax() |
14
|
|
|
{ |
15
|
|
|
return $this->datatables |
16
|
|
|
->eloquent($this->query()) |
17
|
|
|
->editColumn('system', function (Role $role) { |
18
|
|
|
return dt_check($role->system); |
19
|
|
|
}) |
20
|
|
|
->addColumn('users', function (Role $role) { |
21
|
|
|
return view('administrator.roles.datatables.users', compact('role'))->render(); |
|
|
|
|
22
|
|
|
}) |
23
|
|
|
->addColumn('permissions', function (Role $role) { |
24
|
|
|
return view('administrator.roles.datatables.permissions', compact('role'))->render(); |
|
|
|
|
25
|
|
|
}) |
26
|
|
|
->addColumn('action', 'administrator.roles.datatables.action') |
27
|
|
|
->rawColumns(['system', 'users', 'permissions', 'action']) |
28
|
|
|
->make(true); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return \Illuminate\Database\Eloquent\Builder |
33
|
|
|
*/ |
34
|
|
|
public function query() |
35
|
|
|
{ |
36
|
|
|
return Role::query(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return \Yajra\Datatables\Html\Builder |
41
|
|
|
*/ |
42
|
|
|
public function html() |
43
|
|
|
{ |
44
|
|
|
return $this |
45
|
|
|
->builder() |
46
|
|
|
->columns([ |
47
|
|
|
'id', |
48
|
|
|
'name', |
49
|
|
|
'slug', |
50
|
|
|
'system' => ['class' => 'text-center', 'width' => '30px', 'title' => 'Sys'], |
51
|
|
|
'users' => ['orderable' => false, 'searchable' => false, 'class' => 'text-center'], |
52
|
|
|
'permissions' => ['orderable' => false, 'searchable' => false, 'class' => 'text-center'], |
53
|
|
|
'created_at', |
54
|
|
|
'updated_at', |
55
|
|
|
]) |
56
|
|
|
->addAction(['width' => '60px']) |
57
|
|
|
->parameters([ |
58
|
|
|
'stateSave' => true, |
59
|
|
|
'order' => [[0, 'desc']], |
60
|
|
|
'buttons' => [ |
61
|
|
|
[ |
62
|
|
|
'extend' => 'create', |
63
|
|
|
'text' => '<i class="fa fa-plus"></i> ' . trans('cms::role.datatable.buttons.create'), |
64
|
|
|
], |
65
|
|
|
'export', |
66
|
|
|
'print', |
67
|
|
|
'reset', |
68
|
|
|
'reload', |
69
|
|
|
], |
70
|
|
|
]); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: