【发布时间】:2019-04-02 22:29:28
【问题描述】:
我正在尝试编写搜索代码 这是搜索方法:
public function searchcontent(){
$searchkey = \Request::get('title');
$customer = customers::where('customer_name','like','%'.$searchkey. '%')->orderBy('id')->paginate(5);
return view('customers.search',['customer'=>$customer]);
}
这就是风景
@if(count($customer)>0)
@foreach($customer as $user)
<tr>
<td>{{$user->id}}</td>
<th>{{$user->name}}</th>
<th>{{$user->email}}</th>
<th>{{$user->phone}}</th>
<th>{{$user->city}}</th>
<tr>
@endforeach
@endif
<form class="form-header" action="{{url('tsearchcontent')}}" method="GET">
{{csrf_field()}}
<input class="au-input au-input--xl" type="text" name="title" placeholder=",,,,." />
<button class="au-btn--submit" type="submit">
<i class="zmdi zmdi-search"></i>
</button>
</form>
我得到了这个错误 count():参数必须是数组或者实现了Countable的对象
【问题讨论】:
标签: laravel