How to insert an empty string into database instead of null?
Hi there,
i'm just starting off with voyager and wave and can't figure out how to save an empty string to a database field instead of a null value.
In the documentation it says: "NULL VALUES: You might want to save an input field into the database as a null value instead of an empty string. (...)" This lets me suspect, normally an empty field would be saved as an empty string and if I want a null value I have to declare it in the BREAD. But as it happens empty fields are always stored as a null value.
When I change the database to "not null" the field is automatically required. No save possible with an empty field. I already tried to set a default value of "". But it also didn't work...
Can someone help or any suggestions?
Hi there,
You can specify a default value when creating your database table, rather than when creating the bread. For example, you can define this in your Laravel migration for that specific table:
Schema::table('your_table_here', function (Blueprint $table) {
$table->string('some_column_here')->default('');
});
That way the default would be set to an empty string rather than NULL and you will not get that error.
Let me know how it goes.















