|
|
@ -30,7 +30,8 @@ class MenuController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function edit($id){ |
|
|
|
public function edit($id) |
|
|
|
|
|
|
|
{ |
|
|
|
if (!$id || (int) $id < 0 || $id == "") { |
|
|
|
if (!$id || (int) $id < 0 || $id == "") { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
die(); |
|
|
|
die(); |
|
|
@ -108,7 +109,13 @@ class MenuController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function listMenu($id) |
|
|
|
public function listMenu($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$dataParent = RoleMenu::select("m_menu.*") |
|
|
|
$dataParent = RoleMenu::select( |
|
|
|
|
|
|
|
'm_menu.*', |
|
|
|
|
|
|
|
"t_roles_menu.create", |
|
|
|
|
|
|
|
"t_roles_menu.read", |
|
|
|
|
|
|
|
"t_roles_menu.update", |
|
|
|
|
|
|
|
"t_roles_menu.delete" |
|
|
|
|
|
|
|
) |
|
|
|
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id') |
|
|
|
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id') |
|
|
|
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id') |
|
|
|
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id') |
|
|
|
->whereNull('m_menu.parent_id') |
|
|
|
->whereNull('m_menu.parent_id') |
|
|
@ -127,7 +134,13 @@ class MenuController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
protected function getChildrenMenu($id, $role_id) |
|
|
|
protected function getChildrenMenu($id, $role_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$dataChildren = RoleMenu::select("m_menu.*") |
|
|
|
$dataChildren = RoleMenu::select( |
|
|
|
|
|
|
|
'm_menu.*', |
|
|
|
|
|
|
|
"t_roles_menu.create", |
|
|
|
|
|
|
|
"t_roles_menu.read", |
|
|
|
|
|
|
|
"t_roles_menu.update", |
|
|
|
|
|
|
|
"t_roles_menu.delete" |
|
|
|
|
|
|
|
) |
|
|
|
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id') |
|
|
|
->join('m_menu', 'm_menu.id', '=', 't_roles_menu.menu_id') |
|
|
|
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id') |
|
|
|
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id') |
|
|
|
->where('m_roles.id', $role_id) |
|
|
|
->where('m_roles.id', $role_id) |
|
|
@ -136,8 +149,7 @@ class MenuController extends Controller |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
$children = []; |
|
|
|
$children = []; |
|
|
|
if ($dataChildren) { |
|
|
|
if ($dataChildren) { |
|
|
|
foreach($dataChildren as $data) |
|
|
|
foreach ($dataChildren as $data) { |
|
|
|
{ |
|
|
|
|
|
|
|
$data->children = $this->getChildrenMenu($data->id, $role_id); |
|
|
|
$data->children = $this->getChildrenMenu($data->id, $role_id); |
|
|
|
$children[] = $data; |
|
|
|
$children[] = $data; |
|
|
|
} |
|
|
|
} |
|
|
|