我怎样才能在 laravel 中获取 create:: 中的最后一个插入 ID

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

如何获取 laravel 中最后插入的 ID。我正在使用下面给出的 eloquent 方式插入记录

OutSideCity::create($Tariff3Data);

如何获取上述查询的最后插入 ID?

如果我使用

$FreshTripEntry->save();

我可以通过 $Lastid = $FreshTripEntry->id;

获取 Lastinsert id

但是我怎样才能得到 OutSideCity::create($Tariff3Data); 的最后插入 ID?

试试这个..

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

$insertedId = $Traiff->id;