Skip to content

[5.x] Fixed NaN Price and added some caches to attributes#1251

Open
indykoning wants to merge 1 commit intomasterfrom
feature/price-nan
Open

[5.x] Fixed NaN Price and added some caches to attributes#1251
indykoning wants to merge 1 commit intomasterfrom
feature/price-nan

Conversation

@indykoning
Copy link
Copy Markdown
Member

Running toArray would cause the price to be null while ->price would return the correct price.
This would result in NaN prices for products that are out of stock.

The code causing this is https://github.com/laravel/framework/blob/f374d48bc97144bf2ed6e76b1fa2743e615ad446/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L249
By default they pass null as argument to any mutator added to the $appends

Which we can fix by getting the value from the underlying store.

@indykoning indykoning requested a review from royduin as a code owner April 3, 2026 13:51
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.

1 participant