Search code examples
laravel-5eloquentnon-nullable

Laravel migration cancel column as nullable


I created a migration with name column making nullable. How can I change name as not nullable? My previous migration code is given below:

Schema::table('users', function($table)
{
    $table->string('name', 50)->nullable();
});

Solution

  • Use this:

    Schema::table('users', function (Blueprint $table) {
        $table->string('name', 50)->nullable(false)->change();
    });