class SearchController extends Controller
{
function action(Request $request, $id)
{
if ($request->ajax()) {
$output = '';
$query = $request->get('query');
if ($query != '') {
$data = Viddes::all()
->where('video_des', 'like', '%' . $query . '%')
->orWhere('creator', 'like', '%' . $query . '%')
->get();
} else {
$data = Viddes::all()
->orderBy('id', 'video_des')
->get();
}
$total_row = $data->count();
if ($total_row > 0) {
foreach ($data as $row) {
$output .= '
<tr>
<td>' . $row->video_des . '</td>
</tr>
';
}
} else {
$output = '
<tr>
<td align="center" colspan="5">No Data Found</td>
</tr>
';
}
$data = array(
'video_des' => $output,
'creator' => $total_row
);
echo json_encode($data);
}
}
}