Hi @13EN , try this way
Monster::whereId($monster_id)->increment('cost');
I've tried mostly everything basically i just want to add the values 0.000005 and 0.000005 together increasing every time a form is submitted. So for example 0.000005 / 0.000010 / 0.000015 and so on but i don't absolutely no idea how to get this to work.
Table 1 cost contains the value to start the sum from
Schema::create('monsters', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->default('orphan');
$table->longText('description');
$table->decimal('cost')->default('0.000005');
$table->string('backgroundcolor')->default('#fae5d6');
$table->timestamps();
});
and heres the code for the increase of the value
Monster::where(['id'=>$monster_id])->increment('cost', +0.000005);
If anyone could point me in the right direction it would be much appreciated, i've tried nearly every table type known to man, downloaded packages, and still can't solve this.
to be honest, i would go for the precision of integers and then divide the result in the view.
making the column an integer or big int is more predictable and you should have no problems incrementing by 5 instead of 0.000005
Then in the model create an accessor that divides the value by 100,000 when it is needed for a view.
basically the same way I would deal with currencies
Please or to participate in this conversation.