私のホームページに検索ボックスがあります。検索ボタンをクリックすると、結果が返されません。laravelのベースURLに対する投稿リクエスト5.3
これは私のフォームです:
{!! Form::open(array('action' => '[email protected]', 'method' => 'post', 'class' => 'form-inline', 'id' => 'search-bar')) !!}
{{ csrf_field() }}
{{Form::select('Location', ['Kasarani','Allsoaps'], null, ['class' => 'form-control', 'placeholder' => 'Location'])}}
{{ Form::select('Size', ['Bedsitter'], null, ['class' => 'form-control', 'placeholder' => 'Size']) }}
{{Form::submit('search', array('class' => 'btn btn-success'))}}
{!! Form::close() !!}
は、これは私のルートです:
Route::get('/', '[email protected]')->name('home.index');
Route::post('/', '[email protected]')->name('home.post.index');
これは私のコントローラです:
public function postIndex(){
$Location = Input::get('Location');
$Size = Input::get('Size');
$validator= Validator::make(
array(
'Location'=>$Location,
'Size'=>$Size
),
array(
'Location'=>'required',
'Size'=>'required'
)
);
if ($validator->fails()) {
return redirect()->route('home.index')->withErrors($validator);
// echo "fail";
}else{
$houses=DB::table('houses')->where('Location', $Location)->where('Size', $Size)->get();
return View('pages.home')->withHouse($houses);
}
}
誰もが私が行方不明です何を知っていますか?
場合 'DD($場所);'や 'DD($サイズ); 'postIndex()'の中に(リダイレクトの前に)何か見えますか? –
あなたのビューコードと 'houses'テーブル構造を共有できますか? – Sandeesh