Answer the question
In order to leave comments, you need to log in
How to pass a search query route?
Good afternoon, I'm doing a search for the site, tell me how to transfer the search query to the address bar.
Here is the search form
{!! Form::open(['url' => route('search')]) !!}
<input id="appendedInputButton" size="16" name="search" type="text" placeholder="Поиск..."><button class="btn" type="submit"><i class="icon-search"></i></button>
{!! Form::close() !!}
public function search(Request $request)
{
$search = '%'.$request->search.'%';
$posts = Post::where('text', 'like', $search)->paginate(env('PAGINAV'));
$title = 'Резальтаты поиска по запросу: '.$request->search;
return view('search', ['posts' => $posts, 'title' => $title]);
}
Route::post('search/{search?}', '[email protected]')->name('search');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question