Search
 
SCRIPT & CODE EXAMPLE
 

PHP

pagination with search query in laravel

  {{ $products->appends($_GET)->links()}}
Comment

laravel pagination with search filter

// if $id has value it will include "where('id','<',$id) else will return all"
$wells = DB::table('well_s')
        ->when($id, function ($query, $id) {
            return $query->where('id','<',$id);
        })
        ->paginate(20);
Comment

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
Comment

laravel 8 search with pagination

//web.php
    Route::get('contact-search',[ContactController::class,'search'])->name('contact.search');

//ui.blade.php
  <form action="{{route('contact.search')}}" method="get">
    <div class="me-2">
      <div class="input-group">
      <input type="text"  name="search" value="{{request('search')}}" class="form-control border border-primary" placeholder="Search" required>
      <button class="btn btn-outline-primary" type="submit">
      <i class="fa-solid fa-search"></i>
      </button>
      </div>
    </div>
  </form>
  {{ $contacts->appends(Request::all())->links() }}
  
//_Controller.php
public function search(IlluminateHttpRequest $request){
        $searchKey = $request->search;
        $contacts = Contact::where("name","LIKE","%$searchKey%")->orWhere("phone","LIKE","%$searchKey%")->paginate(5);
        return view('contact.index',compact('contacts'));
    }


Comment

Laravel 7 pagination with search filter

$tests = DB::table('view_tests')
    ->whereIn('metric_id',$metricsIds)
    ->where('name', '=', $var)
    ->paginate(4);
Copy code
Comment

PREVIOUS NEXT
Code Example
Php :: closure in php 
Php :: show date php by letters 
Php :: laravel link to css or image 
Php :: getting routes in middleware laravel 
Php :: multiline string php 
Php :: creating jobs laravel 
Php :: magento show which user updated the product 
Php :: list function php 
Php :: laravel blade @if 3 varabile 
Php :: how to hide submenu admin wordpress 
Php :: doctrine where 
Php :: laravel 8 jwt api authentication 
Php :: create factory in laravel 8 
Php :: sass for php 
Php :: template engine php 
Php :: PHP if...else...elseif Statements 
Php :: laravel create command tutorial 
Php :: where is cache file in laravel 
Php :: php qrcode 
Php :: router php 
Php :: laravel 8 login logout 
Php :: route group laravel 8 
Php :: Custom search form 
Php :: PHP metaphone — Calculate the metaphone key of a string 
Php :: add line in string column export php 
Php :: slim disable display error details 
Php :: php count words in string 
Php :: how to get session variables from cookie string 
Php :: command working in terminal but working from code php 
Php :: call stored procedure in laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =