dr_quantity在控制器中具有的总和,然后返回视图模型
public function searchmedreport()
{
$search = \Request::get('search');
$total = DB::table('distribution_records')->where('id', Auth::user()->id)
->sum('medicine_name', 'LIKE', '%'.$search.'%');
$records = DistributionRecord::whereRaw("Concat(dr_fname,' ',dr_lname) LIKE '%{$search}%' ")
->orWhere('medicine_name','LIKE','%'.$search.'%')
->orWhere('date_requested','LIKE','%'.$search.'%')
->orderby('id')->paginate(5000);
return view('forms.searchmedreport',['records'=>$records,'total'=>$total]);
}
和
<b><h4>Total Number of Medicine Distributed: {{$total}} </b></h4>
把总数
慕标5832272