Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

popolla said:

"After saving or creating a new model that uses auto-incrementing IDs, you may retrieve the ID by accessing the object's id attribute".

I'd swear that I actually tried this before and it didn't work. blush Thanks, it does work :)

Last updated 2 years ago.
0

Model->create() will save it into the table and then update the new saved model variable and then you can use $model->id to get the new incremented id

0

Submit and redirect?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

akalajzi akalajzi Joined 9 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.