'staff_2', 'requestData' => [ 'id' => [ 'validation' => DataValidator::dataStoreId('customfield'), 'error' => ERRORS::INVALID_CUSTOM_FIELD, ], ] ]; } public function handler() { $customField = Customfield::getDataStore(Controller::request('id')); foreach(User::getAll() as $user) { $customFieldValueList = $user->xownCustomfieldvalueList ? $user->xownCustomfieldvalueList : []; foreach($customFieldValueList as $customFieldValue) { if($customFieldValue->customfield->id == $customField->id) { $user->xownCustomfieldvalueList->remove($customFieldValue); } } $user->store(); } $customField->delete(); Response::respondSuccess(); } }