Making a column nullable in Laravel migration

If you want a column in the table to be nullable and on rollback or up function and on down function, you want it not nullable.

In Laravel version 5 you can write:


For Laravel version 4 you need to write raw SQL queries:

// getting Laravel App Instance

   $app = app();

  // getting laravel main version

   $laravelVer = explode('.',$app::VERSION);

    switch ($laravelVer[0]) {

        case('5') :               

            Schema::table('pro_categories_langs', function(Blueprint $t) {

                $t->string('name', 100)->nullable()->default(null)->change();



        default :               

             DB::statement('ALTER TABLE `pro_categories_langs` MODIFY `name` VARCHAR(100) NULL;');