我正在尝试创建一个页面,我可以在其中查看数据库中的所有人并对其进行编辑.我做了一个表格,我从某些字段的数据库填写数据.
我想通过Next和Previous按钮浏览它们.
为了生成下一步,我必须使用大于当前ID的ID来加载下一个配置文件.
为了生成上一步,我必须将ID小于当前的ID以加载先前的配置文件.
我的路线:
Route::get('users/{id}','UserController@show');
Run Code Online (Sandbox Code Playgroud)
控制器:
public function show($id)
{
$input = User::find($id);
// If a user clicks next this one should be executed.
$input = User::where('id', '>', $id)->firstOrFail();
echo '<pre>';
dd($input);
echo '</pre>';
return View::make('hello')->with('input', $input);
}
Run Code Online (Sandbox Code Playgroud)
查看: 按钮:
<a href="{{ URL::to( 'users/' . $input->id ) }}">Next</a>
Run Code Online (Sandbox Code Playgroud)
获取当前ID并增加它的最佳方法是什么?