【发布时间】:2018-09-15 02:09:13
【问题描述】:
我写了一个代码在数据表中搜索,输入一个 id 和客户名称,但我需要搜索额外的字段而不指定列。
我需要按列搜索,有搜索功能的控制器:
public function search(Request $request)
{
if ($request->ajax()) {
$output = "";
$indents = DB::table('indents')
->where('id', 'LIKE', '%' . $request->search . '%')
->orwhere('customer_name', 'LIKE', '%' . $request->search . '%')
->orwhere('*', 'LIKE', '%'.$request->search. '%')
->get();
$count=1;
foreach ($indents as $key => $indent) {
$output .= '<tr>' .
'<td>'.$count++.'</td>'.
// '<td>' . $indent->id . '</td>' .
'<td>' . $indent->customer_name . '</td>' .
'<td>' . $indent->phone_no . '</td>' .
'<td>' . $indent->date_of_delivery . '</td>' .
'<td>' . $indent->delivery_at . '</td>' .
'<td>' . '.<a href="' . route('edp.show', $indent->id) . '">.' . '<img src="assets/images/select.jpg" class="imgsize">.' . '</a>.' . '</td>' .
'</tr>';
}
return Response($output);
}
}
【问题讨论】:
标签: php laravel laravel-5.5 laravel-5.6