Your default is over riding the null value. Should be one or the other.
Nov 8, 2016
2
Level 1
1366 Incorrect decimal value Laravel
I have driver model with this condition :
protected $fillable = [
'hourly_rate',
'ot_hourly_rate',
'commission_rate',
'basic_salary',
'join_date',
];
and here's my migration code :
public function up()
{
Schema::table('drivers', function ($table) {
$table->integer('hourly_rate', 24,2)->nullable()->default(0);
$table->decimal('ot_hourly_rate', 24,2)->nullable()->default(0);
$table->decimal('commission_rate', 24,2)->nullable()->default(0);
$table->decimal('basic_salary', 24,2)->nullable()->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('drivers', function ($table) {
$table->dropColumn('hourly_rate');
$table->dropColumn('ot_hourly_rate');
$table->dropColumn('commission_rate');
$table->dropColumn('basic_salary');
});
}
the problem is when I try to create driver and didn't fill those field it says error decimal value. decimal can't store empty string as NULL at database ?
note : those field is not required.
Please or to participate in this conversation.