如何获取最后插入的自动递增 id 并将其插入另一个 table in laravel?
How to get last inserted auto-incremented id and insert it into another table in laravel?
我有 journallog 和 subjournallog tables。当我在 journallog table 中插入数据时,我想从中获取自动递增的 id 并插入到 subjournallog table 中。有人可以举例说明如何做到这一点吗?
$user = User::create(['emai' => 'EMAIL', 'password' => 'PASSWORD']);
创建用户并 returns 它。
ID
可通过 $user->id
访问
我有 journallog 和 subjournallog tables。当我在 journallog table 中插入数据时,我想从中获取自动递增的 id 并插入到 subjournallog table 中。有人可以举例说明如何做到这一点吗?
$user = User::create(['emai' => 'EMAIL', 'password' => 'PASSWORD']);
创建用户并 returns 它。
ID
可通过 $user->id