Skip to content

Conversation

@delamux
Copy link
Collaborator

@delamux delamux commented Feb 17, 2024

  • Refactor and remove deprecated methods

@delamux delamux requested a review from steinkel February 17, 2024 14:59

foreach ((array)$data['users'] as $user) {
$entity = $model->newEntity();
$model->saveMany($entities);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if save fails?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I will handle the error.

$item->set('state', 0);
$model->save($item);
$item->set('state', Notification::READ_STATUS);
$this->table->save($item);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if save fails?

foreach ((array)$data['users'] as $userId) {
$finalData = array_merge($data, ['user_id' => $userId]);
$entity = $model->newEntity($finalData);
$entity->set('vars', $data['vars']);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I needed it to do this because for any reason, passing the data in the newEntities with the arrays of arrays was not entering in the property 'vars' of the Entity which is in charge of jsonEncode. Was setting up the vars as empty string


foreach ((array)$data['users'] as $user) {
$entity = $model->newEntity();
$model->saveMany($entities);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I will handle the error.

@delamux delamux requested a review from steinkel February 20, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants