
You can now easily change the default database auto increment value in Laravel
Laravel 8 adds a brand new method to make changing the auto-increment starting value easy, and here is the official announcement made on Twitter:
Sneaking this into Laravel 8.x today… pic.twitter.com/Bg24S7iX4j
— Taylor Otwell (@taylorotwell) September 6, 2020
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id()->startingValue(1200);
...
Changing the auto-increment through the various database platforms has always been possible, but you needed to do it via a raw command. With the addition of the startingValue
method, this allows you to set the first number the auto-increment will start at in a fluent Laravel way.
For most apps, you will probably not need this but in those situations where you do not want a record starting at one, it’s a handy option.
Filed in: News / Eloquent / MigrationsNewsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.
Laravel Jobs

- Full Stack PHP (Mid-Level/Senior) Programmer
-
Remote
PhoneBurner - Software Developer
-
Remote, (US & Canada Only)
Patient Prism - Web Application Developer
-
Chicago Loop
Leading Real Estate Companies of the World - Multiple Laravel Developers (Part-Time)
-
Remote, USA Only
The Great Escape Room - Software Developer
-
Remote (US & Canada)
Alley
Laravel 8 is Now Released!
Laravel 8 is now released and includes many new features including Laravel Jetstream, a models directory, model facto…
Sqreen: Application Security for Laravel Apps (sponsor)
Sqreen is an Application Security Management platform that helps developers and security teams protect, observe, and…