Home >PHP Framework >Laravel >Laravel can elegantly modify the default auto-increment ID start value!
The following tutorial column will introduce you to an iconic method added in Laravel 8. I hope it will be helpful to friends in need!
#Laravel 8 has added an iconic method that can elegantly modify the starting value of the auto-increment ID. Today Taylor Otwell officially announced this new feature on Twitter :public function up(){ Schema::create('posts', function (Blueprint $table) { $table->id()->startingValue(1200); ...Although you can change the starting value of the auto-increment ID through various database platforms, you always need to enter a line of instructions to achieve it. With the startingValue method above, you can use a more "Laravel" approach to setting the starting value of the auto-incrementing ID.
For most applications, you may not need this, but if you don't want to start counting IDs from 1, this is a convenient option.
小声bb: For example, the reserved 4-digit QQ number?
Original text: https://laravel-news.com/laravel-auto-increment
The above is the detailed content of Laravel can elegantly modify the default auto-increment ID start value!. For more information, please follow other related articles on the PHP Chinese website!