kdiaz489's avatar

6 Digit Zerofill Id

Is there a way to create a 6 digit, zerofill id through Laravel? I've been doing it through phpmyadmin gui. Not sure how to replicate when Im creating a migration.

0 likes
2 replies
Teodoro's avatar

Maybe a little late for this, but for someone who needs zerofill for some reason, Laravel doesn't have it by default because it's specific to MySQL. However, you can use an ALTER TABLE statement in your migration to achieve this. Here's an example:

Schema::create('your_table', function (Blueprint $table) {
	$table->integer('zero_fill_column');
});
DB::statement('ALTER TABLE your_table CHANGE zero_fill_column zero_fill_column INT(6) UNSIGNED ZEROFILL')
1 like

Please or to participate in this conversation.