If you look for something like this:
function action(Request $request)
{
if($request->ajax())
{
$output = '';
$query = $request->get('query');
if($query != '')
{
$data = DB::table('tbl_customer')
->where('CustomerName', 'like', '%'.$query.'%')
->orWhere('Address', 'like', '%'.$query.'%')
->orWhere('City', 'like', '%'.$query.'%')
->orWhere('PostalCode', 'like', '%'.$query.'%')
->orWhere('Country', 'like', '%'.$query.'%')
->orderBy('CustomerID', 'desc')
->get();
}
else
{
$data = DB::table('tbl_customer')
->orderBy('CustomerID', 'desc')
->get();
}
$total_row = $data->count();
if($total_row > 0)
{
foreach($data as $row)
{
$output .= '
<tr>
<td>'.$row->CustomerName.'</td>
<td>'.$row->Address.'</td>
<td>'.$row->City.'</td>
<td>'.$row->PostalCode.'</td>
<td>'.$row->Country.'</td>
</tr>
';
}
}
else
{
$output = '
<tr>
<td align="center" colspan="5">No Data Found</td>
</tr>
';
}
$data = array(
'table_data' => $output,
'total_data' => $total_row
);
echo json_encode($data);
}
}
This tutorial explains all you need, just follow with your own data https://www.webslesson.info/2018/04/live-search-in-laravel-using-ajax.html?m=1