Skip to content

incrementEach and decrementEach dont respect where query when used for eloquent model #49009

Closed
@royduin

Description

@royduin

Laravel Version

10.32.1

PHP Version

8.1.22

Database Driver & Version

No response

Description

Related: #45577 and #48595, copied the description from that issue:

incrementEach() and decrementEach() dont respect where condition when used for eloquent model.

$user = User::where('shop_id', 1)->first();
$user->decrementEach(['counter' => 1, 'balance' => 100]);

All users in the table are decremented whatever 'shop_id' they have.

Please note that the problem is only if executed via eloquent model , but works correctly if executed via direct query as below

User::where('shop_id', 1)->decrementEach(['counter' => 1, 'balance' => 100]); // works correctly

Steps To Reproduce

See description

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions