Skip to content

Result of Eloquent Models not expected data #54670

@herisetiyawan

Description

@herisetiyawan

Laravel Version

11.41.3

PHP Version

8.3.12

Database Driver & Version

11.6.2-MariaDB-ubu2404

Description

Eloquent Models show un expected data

Steps To Reproduce

create database with table below
DROP TABLE IF EXISTS market_carts`;

CREATE TABLE market_carts (
id char(36) NOT NULL,
customer_id varchar(255) NOT NULL,
store_id varchar(255) NOT NULL,
store_name varchar(255) DEFAULT NULL,
product_id varchar(255) NOT NULL,
quantity int(11) NOT NULL DEFAULT 1,
final_price bigint(20) NOT NULL,
total bigint(20) NOT NULL,
created_at timestamp NULL DEFAULT NULL,
updated_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

LOCK TABLES market_carts WRITE;
/*!40000 ALTER TABLE market_carts DISABLE KEYS */;

INSERT INTO market_carts (id, customer_id, store_id, store_name, product_id, quantity, final_price, total, created_at, updated_at)
VALUES
('0fa201eb-92e3-4d0b-acae-0148c85397bd','4','3','Toko Toples','5886f458-9bff-4c74-b3dd-04ae606a0bb5',1,8000,8000,'2025-02-18 10:44:25','2025-02-18 10:44:25'),
('2f30428d-442c-4a06-964f-e20952bdafe7','3','2','JAKARTA INDO','5b6c14c8-4cdb-42cb-8792-d649559945a1',2,90000,180000,'2025-02-18 10:04:43','2025-02-18 10:14:40'),
('4beeb2aa-947c-4a1e-bb71-b7b46f777b06','4','2','JAKARTA INDO','5b6c14c8-4cdb-42cb-8792-d649559945a1',5,90000,450000,'2025-02-18 10:44:32','2025-02-18 12:49:00'),
('ce956148-4726-42c0-b42e-a40aa63869dd','4WrVDGSnp0Lh3Mk6Jj2EOmOu739RB12CCqG4y30x','2','JAKARTA INDO','5b6c14c8-4cdb-42cb-8792-d649559945a1',1,90000,90000,'2025-02-18 16:17:43','2025-02-18 16:17:43');

/*!40000 ALTER TABLE market_carts ENABLE KEYS */;
UNLOCK TABLES;`

use Eloquent Models

MarketCart::where([ 'customer_id'=>4 ]) ->orderBy('store_id', 'ASC') ->orderBy('product_id', 'ASC') ->get();

result will show data with customer_id 4 and data with 4WrVDGSnp0Lh3Mk6Jj2EOmOu739RB12CCqG4y30x

expected only show data with customer_id 4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions