I believe this is designed this way to limit number of SQL queries. If you need to get actual data saved in the database, you need to obtain this record explicitely, just the way you did :)
kokokurak said:
I believe this is designed this way to limit number of SQL queries. If you need to get actual data saved in the database, you need to obtain this record explicitely, just the way you did :)
thanks for your reply.
I dig into the source code and take some time thinking about the implementation.
I think it make sense: no way that you can create the record and retrieve its full data in just a sql command.
Exactly, INSERT query doesn't return actual row.
You can do it like this and get the attributes back
$user = New User;
$user->name = 'John'
$user->email = '[email protected]';
$user->save();
//Now user will have all the attributes from the model, even ones you didn't set.
$new_id = $user->id;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community