I have a simple search function
public function search(Request $request)
{
$posts = Post::where('title', 'like', '%'.$request->term.'%')->paginate(10);
return view('posts.search', compact('posts'));
}
My route:
Route::group(['prefix' => 'posts', 'as' => 'posts.'], function () {
Route::post('/search', ['as' => 'posts', 'uses' => 'SearchController@posts']);
});
And my opinion:
<form action="{{ route('searches.posts') }}" method="post">
{{ csrf_field() }}
<div class="input-field col s6">
<input class="input blue-text text-lighten-3" type="text" name="term">
</div>
<div class="input-field col s6">
<button type="submit">
<i class="material-icons">search</i>
</button>
</div>
</form>
I call this function after sending and receiving a new view with all the elements related to the search. So far this works, but if I refresh the page, I get the following error:
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message
source
share