Home > PHP Framework > Laravel > Laravel can elegantly modify the default auto-increment ID start value!

Laravel can elegantly modify the default auto-increment ID start value!

藏色散人
Release: 2020-09-08 09:12:54
forward
2982 people have browsed it

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 :

Laravel can elegantly modify the default auto-increment ID start value!

public function up(){
    Schema::create('posts', function (Blueprint $table) {
        $table->id()->startingValue(1200);
        ...
Copy after login

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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template