Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel 7 pagination with search filter

$tests = DB::table('view_tests')->whereIn('metric_id',$metricsIds)->paginate(4);

        $tests = $tests->filter(function ($item) use ($var) {
                    return false !== stristr($item->name, $var) || 
                    false !== stristr($item->section_name, $var) || 
                    false !== stristr($item->method, $var) || 
                    false !== stristr($item->limit, $var) || 
                    false !== stristr($item->accredited_detail, $var);

               return view('frontend.test_detailes',compact('tests'))->render();
Copy code
Source by programmierfrage.com #
 
PREVIOUS NEXT
Tagged: #Laravel #pagination #search #filter
ADD COMMENT
Topic
Name
1+6 =