我目前正在学习laravel和我的小项目,现在我遇到了一些小问题。路由到控制器问题
我试图来处理URL即PHP输入http://example.com/?page=post&id=1
我现在有这在我的控制器post.blade.php
public function post($Request $request)
{
$page = $request->input('page');
$id_rilisan = $request->input('id');
$post = Rilisan::where('id_rilisan', '=', $id_rilisan)->first();
if($post = null)
{
return view('errors.404');
}
return view('html.post')
->with('post', $post);
}
,这是控制器
Route::get('/', '[email protected]');
Route::get('/{query}', '[email protected]');
如何处理php输入路由到控制器?我现在很迷茫,我已经试过了路线等几个方法::获得
所以我不需要其他Route :: get? – nothingexceptme
@nothingexceptme如果你不使用它,你可以删除它。第二条路由将会捕获像'/ some-string'这样的URIs –