早上好!我正在开发个人资料用户,我有以下疑问。
我知道我的上一个用户是以下表格
$full = User::orderBy('id','desc')->take(1)->get();
我以这种雄辩的方式接受了这个json。
. [{"id":58,"nif":"AAAA","name":"AAA","cognoms":"AAA","file":"uploads\/\/f0414.gif","birthday":"0000-00-00","presentacion":"descripciones","email":"nxnxbcbbcvcc@pesssdpepefgpepepep.com","idempresa":1,"id_poblacion":2254,"id_online":0,"created_at":"2015-05-24 00:00:40","updated_at":"2015-05-24 00:00:40"}]
但我不知道如何获得身份和总和。
答案 0 :(得分:1)
然后只需将 1 添加到您last inserted id
$model = new User();
$model->save();
$insert_id = $model->id; #This is the last inserted id
在此之后,只需将 1 添加到变量$insert_id
$next_id = $insert_id + 1;
如果你想获取最后两条记录,那么
$full = User::orderBy('id','desc')->take(2)->get();