1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace App\Http\Controllers\Backend\Access\Role;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Access\Role\ManageRoleRequest;
use App\Repositories\Backend\Access\Role\RoleRepository;
use Yajra\DataTables\Facades\DataTables;
/**
* Class RoleTableController.
*/
class RoleTableController extends Controller
{
/**
* @var RoleRepository
*/
protected $roles;
/**
* @param RoleRepository $roles
*/
public function __construct(RoleRepository $roles)
{
$this->roles = $roles;
}
/**
* @param ManageRoleRequest $request
*
* @return mixed
*/
public function __invoke(ManageRoleRequest $request)
{
return Datatables::of($this->roles->getForDataTable())
->escapeColumns(['name', 'sort'])
->addColumn('permissions', function ($role) {
if ($role->all) {
return '<span class="label label-success">'.trans('labels.general.all').'</span>';
}
return $role->permission_name;
})
->addColumn('users', function ($role) {
return $role->userCount;
})
->addColumn('actions', function ($role) {
return $role->action_buttons;
})
->make(true);
}
}