Сама форма
<form id="searchh" action="{{ url('/search') }}" method="get">
<p id="bilet">Поиск билетов</p>
<div id="search1">
<input list="search" type="search" id="city" name="city" placeholder="Откуда">
<input type="search" name="kuda" id="city" placeholder="Куда">
<input type="date" name="date">
<button type="submit">Найти</button>
<input type="hidden" name="action" value="{{ '$search' }}">
</div>
</form></b>
Маршрут
Route::get('/search/', [SearchController::class, 'search'])->name('search');
Контроллер
public function search(Request $request){
$search = $request->input('search');
$posts = DB::table('cities')
->where('name', 'LIKE', "%{$search}%")
->get();
return view('search', compact('posts'));
}
Страница вывода
@if (isset($citi))
<table class="table-hover">
<thead>
<tr>
</tr>
</thead>
<tbody>
@if($posts->isNotEmpty())
@foreach ($posts as $post)
<div class="post-List">
<p>{{ Spost-nane }}</p>
@endForeach
@else
<div>
<h2>No posts Found</h2>
</div>
@endif
</tbody>
</table>
@endif