How to reset auto increment in laravel user deletion?

前端 未结 4 631
北恋
北恋 2021-02-05 09:17

I have been struggling to find out a way to reset the auto increment value in Laravel 4 but it seems that this functionality is not embedded in laravel 4 at least for now. so i

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 09:54

    use Illuminate\Support\Facades\DB;
    
    public function refreshDB()
    {
        $max = DB::table('users')->max('id') + 1; 
        DB::statement("ALTER TABLE users AUTO_INCREMENT =  $max");
    }
    
    // Note: This solution is for resetting the auto_increment of the table without truncating the table itself 
    

提交回复
热议问题