l5-repository icon indicating copy to clipboard operation
l5-repository copied to clipboard

Update with multiple where

Open namttdh opened this issue 6 years ago • 5 comments

Hi there, I have a question very normal for you. How can i get update with another two fields without using id? Thank you for helping.

namttdh avatar Mar 16 '18 07:03 namttdh

same problem.. Anyone with an answer?

anthonyvancauwenberghe avatar Apr 25 '18 23:04 anthonyvancauwenberghe

Same problem.

kalemdzievski avatar Dec 27 '18 13:12 kalemdzievski

me too,same problem

dwt11 avatar Dec 28 '18 14:12 dwt11

https://github.com/andersao/l5-repository/pull/176 the update method can receive an array in its second argument,

dwt11 avatar Dec 28 '18 14:12 dwt11

this topic is 3 years old, but I didn't want to open a new one. I have just started using this package that is awesome for a lot of stuff.

Anyway, let's say that I have a where array like the following one:

$where = [
  'field_one' => 1,
  'field_two' => "john"
  'field_three' => 1990
];

and I want to set a specific field for entries matching these criteria:

$updates = [
  'needs_review' => 1
];

For the "delete" operation is easy: $this->repository->deleteWhere($where); . It would be nice to have something like $this->repository->updateWhere($where, $updates);

Let me know if during this time something has changed, or if there is another way to accomplish this task.

Thanks

lorenzosfarra avatar Nov 18 '21 15:11 lorenzosfarra