Support the ongoing development of →
posted 9 years ago
Last updated 1 year ago.

As of now Laravel Schema Builder does not support SET datatype for columns. So, here is an alternative solution until someone add those code to Laravel.

Step 1: Create the table, use ENUM instead of SET.

Schema::create('schools', function($table)
    $table->char('id_number', 6);
    $table->enum('level', array('Preschool', 'Kindergarten', 'Primary', 'Secondary'))->index();	// *** fix this

Now change ENUM to SET.

$table_prefix = DB::getTablePrefix();
DB::statement("ALTER TABLE `" . $table_prefix . "schools` CHANGE `level` `level` SET('Preschool','Kindergarten','Primary','Secondary');");

If you have a better solution, then please let me know.

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?

Debiprasad debiprasad Joined 18 Jun 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.