Closed
Description
Laravel Version
10.45.1
PHP Version
8.3
Database Driver & Version
MYSQL 8.0
Description
I think there is a problem with Laravel's ORM.
We wanted to support both id and slug so this is our query:
$query->whereSlug("02t-19")->orWhere("id", "02t-19")->firstOrFail();
I was amazed that it also finds an id of product 2 with the wrong slug.
Steps To Reproduce
- A table called products is created on the db having slug and id with many records.
- Run the query in route service provider:
Route::bind('product', fn ($value) => Product::whereSlug($value)->orWhere('id', $value)->firstOrFail());
- It returns a record with the id of "2" with the slug of "156-tfb" instead of id "502" and slug of "02t-19"