I am creating a new user. After creating, I need the ID of the user, which is automatically set by the database.
$user = new User();
$user->save();
dd($user->id);
But the response I get is null. Is there a way to get the ID of the user?
I use Sentinel to manage my users. I have adapted the users migration to my needs. Now it looks like this:
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('first_name');
$table->string('last_name');
$table->string('username')->nullable()->unique();
$table->string('email')->nullable();
$table->string('password')->nullable();
$table->text('permissions')->nullable();
$table->string('doodle_token', 64)->nullable()->unique();
$table->timestamps();
$table->engine = 'InnoDB';
});
I'm using Laravel version 5.8