Home > other >  Laravel insert insert data how to return to the primary key id value
Laravel insert insert data how to return to the primary key id value

Time:10-07



Note: the primary key is not to add the Id, the primary key Id is a 32-bit string uuid



CodePudding user response:


Try the model change the primarykey try, you also need to look at the laravel underlying framework model: : create is how to achieve

CodePudding user response:


Using the create () and then will return to insert this data, give it a try,

CodePudding user response:


//input entry
$user=user: : create ($data);
The $user - & gt; The guid.
Try, so I use the

CodePudding user response:


Well well, good luck to you

CodePudding user response:


My also is such, not on the id, changed the id is of type bigInteger, then, after the create return id is 0,, primaryKey set id doesn't work;
Bosses, how to break! : cry:

CodePudding user response:


If the data table has the ID, insertGetId method is used to insert records and return the ID value
Document links: query builder "Laravel 5.6 Chinese document
"

CodePudding user response:

$userId=User: : insertGetId ($data);
  • Related