我遇到了一个问题。
我需要获取插入表中的最后一个id,然后将其添加到同一张表中。我的表中有两个字段"id"和"translation-of",它们都应该保存相同的值。id字段是自动递增的。如何实现这个功能???如果使用Excel上传类别,也会遇到同样的问题...请帮帮我...
我的控制器函数是:
我的控制器函数是:
$insert[] = ['translation_lang'=>'en','parent_id' =>$a[0],'name' => $value->name,'slug' =>$value->name,'description' => $value->description,'picture'=>$pic,'active'=>1];
$last_id = \DB::table('categories')->max('id');
if(!empty($insert)){
\DB::table('categories')->insert($insert);
\DB::table('categories')->where('id2',$last_id)->update(['translation_of' => $last_id]);
return Redirect::to('admin/category');
}
等待响应。