BLOB, TEXT, GEOMETRY and JSON column can't have a default value.
If you are using Eloquent model then you can add default values using:
protected $attributes = [
'notification_via' => ['database', 'via']
];
I want to set default value for json data type:
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->json('notifications_via')->default(['database','via']);
$table->timestamps();
});
In user model i cast notifications_via to array but i'll give error of:
Array to string conversion
BLOB, TEXT, GEOMETRY and JSON column can't have a default value.
If you are using Eloquent model then you can add default values using:
protected $attributes = [
'notification_via' => ['database', 'via']
];
Please or to participate in this conversation.