So I am running a transaction that should create a user, and fire off an event to do additional things with the new user id, including creating a settings table where the foreign key user\_id in the settings table is the newly created user\_id (providing the transaction works of course).

Here is what I have so far:

```
DB::beginTransaction();

try {
    DB::table('users')->insert([
              'email' => $email,
              'password' => $password
    ]);

    event(new UserWasStored($newUserId)); // How do I get the $newUserId?
}
catch(\Exception $e) {
    DB::rollback();
}

DB::commit();

```

How can I get the `$newUserId` passed to the event within the transaction?