public function testGetListPermissionNull() { $this->withoutMiddleware(); $this->call('POST', '/nodePermission', ['name' => 'Login', 'display_name' => 'User login', 'description' => 'Des', 'parent_id' => 1]); // CHange root node id $root = NodePermission::find(1); $root->id = 0; $root->save(); $res = $this->call('GET', '/nodePermission'); $this->assertEquals(200, $res->getStatusCode()); $results = json_decode($res->getContent()); $this->assertEquals(null, $results->entities); }
/** * Create permission route action * * @param Request $request * @return Response */ public function store(Request $request, $id = null) { // validate $validator = Validator::make($request->all(), ['route_name' => 'required|max:255|string', 'route_method' => 'required|max:255|string']); if ($validator->fails()) { return response()->json(arrayView('gcl.gclusers::errors/validation', ['errors' => $validator->errors()]), 400); } if (!NodePermission::find($id)) { return response()->json(null, 404); } // add permissions and roles for the route $routePermission = PermissionRoute::setRoutePermissionsRoles($id, $request['route_name'], $request['route_method']); return response()->json(arrayView('gcl.gclusers::routePermission/read', ['routePermission' => $routePermission]), 201); }
/** * Delete permission action * * @return Response */ public function destroy($id = null) { // get permission by id $node = NodePermission::find($id); if (!$node) { return response()->json(null, 404); } // delete permission $deletePermission = $node->delete(); if (!$deletePermission) { return response()->json(null, 500); // @codeCoverageIgnore } return response()->json(null, 204); }