0
フォーム(dropdwon)から値を渡して、この値をURLに追加する必要があります。Laravel 5.2 paramsをURLに追加
私のルートは以下のとおりです。
{!!Form::open(array('action' => '[email protected]', 'method' => 'POST'))!!}
{!! Form::select('city', array('heilbronn' => 'Heilbronn', 'stuttgart' => 'Stuttgart')) !!}
{!!Form::submit('Senden')!!}
{!!Form::close()!!}
そしてこのコントローラー:
public function menue(Request $request, $city = null) {
$searchinput = $request->input('city');
$restaurants = User::with(['articles' => function ($q){
$q->nowpublished();
}]);
if(!is_null($city) && !is_null(User::where('city', $city)->first())) {
$restaurants->where('city', '=', $city);
}
$restaurants = $restaurants->get();
return view('pages.menues')->withRestaurants($restaurants)
//->withArticles($articles)
->withCity($city)
->withSearchinput($searchinput);
}
は私が値($のsearchinput)を追加する必要があるから
Route::get('menues/{city?}', '[email protected]');
Route::post('/', '[email protected]');
は、私は簡単なフォームを持っています特定の都市のエントリのみを表示する前のページ。
とルート 'にあなたのルートを変更する::(「menues」、「をPagesController @ menue」を取得); ' – astratyandmitry
ありがとうastratyandmitry。働いた! – Mamulasa
あなたは大歓迎です:) – astratyandmitry