Created
January 30, 2021 21:20
-
-
Save gentildpinto/4b03c03e4d676423c0b67164af418b37 to your computer and use it in GitHub Desktop.
A simple code to get the next auto increment id from a table in laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Support\Facades\DB; | |
class UserController extends Controller | |
{ | |
/** | |
* @return mixed | |
*/ | |
private function getNextUserId() | |
{ | |
$statement = DB::select("SHOW TABLE STATUS LIKE 'users'"); | |
$nextUserId = $statement[0]->Auto_increment; | |
return $nextUserId; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank's for your hep! :)