fix: [CRUD] accept contain as a parameter for edit, fixes an issue with auth key edits

pull/7493/head
iglocska 2021-06-10 16:21:44 +02:00
parent a61caa3a6a
commit e729ad9225
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 5 additions and 1 deletions

View File

@ -83,6 +83,7 @@ class AuthKeysController extends AppController
return $authKey;
},
'fields' => ['comment', 'allowed_ips', 'expiration'],
'contain' => ['User.id', 'User.org_id']
]);
if ($this->IndexFilter->isRest()) {
return $this->restResponsePayload;

View File

@ -155,12 +155,15 @@ class CRUDComponent extends Component
$query = isset($params['get']) ? $params['get'] : [
'recursive' => -1,
'conditions' => [
'id' => $id
$modelName . '.id' => $id
],
];
if (!empty($params['conditions'])) {
$query['conditions']['AND'][] = $params['conditions'];
}
if (!empty($params['contain'])) {
$query['contain'] = $params['contain'];
}
/** @var Model $model */
$model = $this->Controller->{$modelName};
$data = $model->find('first', $query);