mercredi 10 novembre 2021

Not null violation: 7 ERROR: null value in column - Laravel 5.8

I don't understand this, I alter my table to add these columns

Schema::table('clusters', function($table)
{

    $table->string('ssaEnabled',1)->default('0');
    $table->string('ssaBackendUrl')->default(NULL);
    $table->string('ssaPortalApiUrl')->default(NULL);

});

in my store() I have this

$cluster->ssaEnabled            = Input::get('ssaEnabled','0');
$cluster->ssaBackendUrl         = Input::get('ssaBackendUrl','');
$cluster->ssaPortalApiUrl       = Input::get('ssaPortalApiUrl','');

$cluster->save();

I kept getting

prod.ERROR: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "ssaBackendUrl" violates not-null constraint

Why ??

  1. I set it to default null already
  2. I also add a backup value in my Input::get() in the 2nd param as an empty string

Any hints?

How can I stop that ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire