如何获取OctoberCMS模型最近添加的id?

16 浏览
0 Comments

如何获取OctoberCMS模型最近添加的id?

这个问题已经在这里有了答案:

使用Laravel Eloquent获取最后插入的 id

        $doc->user_id = Auth::getUser()->id;;
        $doc->type = post('type');
        $doc->list_num = post('list_num');
        $doc->ticket = post('ticket');
        $doc->contract = post('contract');
        $doc_id = $doc->save();

我想从数据库中获取最后添加的模型 id。我应该怎么做?

admin 更改状态以发布 2023年5月24日
0
0 Comments
...
$doc_id = $doc->save();
$doc_id  = $doc->id; //id is the primary id you set in model, default is id

:这段文本包含粗体标签,显示为“123”。

0