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 :: php docker offical apache 
Php :: How to show total count in tables using php 
Php :: laravel how can I use the same foreign key twice in a single table 
Php :: get array of last 3 dates with carbon 
Php :: laravel check if collection has value 
Php :: laravel manually authenticate user 
Php :: wordpress get wp roles 
Php :: use session in laravel 
Php :: execute php mysql securely 
Php :: php value in array 
Php :: php get first two paragraphs 
Php :: woocommerce my account php code wordpress 
Php :: replace last two characters string php 
Php :: the requested url was not found on this server. apache/2.4.46 (win64) openssl/1.1.1h php/8.0.1 server at localhost port 80 
Php :: how to excluse csrf in a route laravel 
Php :: using get in laravel blade 
Php :: if statement php 
Php :: Rename route resource in laravel 
Php :: get array value in php 
Php :: how to access array using key in php 
Php :: how to rename a table element in laravel 
Php :: joomla print query 
Php :: sqlstate[22023]: invalid parameter value: 
Php :: why the laravel project have many cache 
Php :: Detect the page realod in php 
Php :: enable trash for media wordpress 
Php :: include navbar or part in layout in laravel blade template 
Php :: laravel compare request domain and app domain and request original domain 
Php :: recursive directory only listing php 
Php :: "IlluminateDatabaseEloquentMassAssignmentException" 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =