public function store(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Permissions', 'create')) {
            return $this->noPermission();
        }
        // custom messages for validation
        $messages = array(
            'id.required' => 'ID is missing',
            'name.required' => 'You cant leave name field empty',
            'permissions.required' => 'Something is wrong, please contact your administrator.',
        );
        // validation
        $validator = Validator::make(
            $request->all(), [
            'id' => 'required',
            'name' => 'required',
            'permissions' => 'required',
            ], $messages
        );
        // if validation fails return json response
        if($validator->fails()) {
            return $this->response("Please check all required fields!", 400, null, false, false, true, $validator->errors());
        }

        $id = $request->id;
        $name = $request->name;
        $permissions = $request->permissions;
        $globalPermissions = $request->globalPermissions;

        if ($id == 0) {
            $slug = str_slug($name, '-');
            $group = \App\Models\UserGroup::create(
                [
                'name' => $name,
                'slug' => $slug
                ]
            );
            $id = $group->groupID;
        }else{
            $postDeletion = DB::table('permissions')->where('groupID', $id)->delete();
        }

        $query = Permission::createGlobalPermissions($globalPermissions, $id);
        $query = array_merge($query, Permission::createPermissions($permissions, $id));

        // make query
        if (count($query)) {
            $permission = Permission::insert($query);
            if ($permission) {
                return $this->response('Permissions updated');
            }
        }
    }