简体   繁体   English

我如何在Laravel中获得create ::中的最后一个插入ID

[英]How can i get the last insert id in the create:: in laravel

How can i get the last inserted id in the laravel. 我怎样才能在Laravel中获得最后插入的ID。 I am using the given below eloquent way to insert the record 我正在使用下面给出的雄辩方法插入记录

OutSideCity::create($Tariff3Data);

How can i get the last insert id for the above query ? 如何获得上述查询的最后一个插入ID?

If i use 如果我用

$FreshTripEntry->save();

I can get the Lastinsert id by $Lastid = $FreshTripEntry->id; 我可以通过$Lastid = $FreshTripEntry->id;

But how can i get the last insert id for the OutSideCity::create($Tariff3Data); 但是我如何获得OutSideCity::create($Tariff3Data);的最后一个插入ID OutSideCity::create($Tariff3Data); ?

Try this.. 尝试这个..

$Traiff=OutSideCity::create($Tariff3Data);

$insertedId = $Traiff->id;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM