Skip to content

Allow 2 decimals for energy amount#6

Open
jbaron-mx wants to merge 1 commit into
hacklabsdev:masterfrom
jbaron-mx:fix-migration
Open

Allow 2 decimals for energy amount#6
jbaron-mx wants to merge 1 commit into
hacklabsdev:masterfrom
jbaron-mx:fix-migration

Conversation

@jbaron-mx

Copy link
Copy Markdown
Contributor

This PR fixes a rounding problem caused by having the amount column defined as float(8,1), where if decreasing the energy by 0.25 for instance, it will be persisted to the database as 0.20

Issue can be recreated in Tinker as follows:

# Add energy of 1 to an energisable model
$hashtag->addEnergy(1);
$hashtag->energy->amount; // 1.0

# Decrease energy by 0.25
$hashtag->decayEnergy(0.25)
$hashtag->refresh(); 
$hashtag->energy->amount; // 8.0 instead of 0.75

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