我目前正在學習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 –