I have a database field that should allow NULL as value but also the values should be unique, the migration line:
$table->string('projet_number')->nullable()->unique();
In mySQL database everything worked fine, somehow NULL was ignore for unique validation. Now I need to migrate my database to Microsoft SQL Server and now this doesn't work anymore because NULL is duplicated:
"message": "SQLSTATE[23000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot insert duplicate key row in object 'dbo.projects' with unique index 'projects_number_unique'. The duplicate key value is ()
This answer describes exactly what I need to to: https://stackoverflow.com/a/767702/3018671
But how I can implement this in Laravel? Also I tried other solutions like this one: https://stackoverflow.com/a/35101246/3018671, But it doesn't work.