@redlik how you saving to your db
Cannot save price variable to table
I have a transaction model with column to save the amount being charged during the transaction. The transaction means buying "credits" for a certain amount, so from my radio tag I read number of credits and using switch case I select the right amount, ie if 5 credits is selected $amount = 39.99 etc.
$amount works fine when making a new charge object with stripe but for some reason I cannot save this variable to the table.
I tried setting it up as decimal, float with 2 decimal places or just float without any parameters and nothing works.
I've dd'ed the variable inside the function and it shows as begin float so what's wrong with my setup? Here's my code snipped:
switch ($credit) {
case 5:
$amount = 39.99;
break;
case 15:
$amount = 99.99;
break;
case 50:
$amount = 249.99;
break;
default:
$amount = 39.99;
}
and my table setup:
$table->float('amount', 8, 2)->nullable();
I had to add nullable to make the function work at all, obviously I don't want that column be blank.
No! You have a variable $amount, which exists separately to the Request object, and/or the Transaction instance. If you show us your remaining code, we can show you where to make that assignment
Please or to participate in this conversation.