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 search and return record with pagination

//make sure that all your queries/builder has ->paginate and not a ->get() or 
//->first() then do {{ $var->links() }} in the blade

        if(empty($request->search)){
            $user = DB::table('users')->Paginate(15);
            return view('/users', ['user' => $user]);
        }else{
            $user = DB::table('users')->where('name', 'like', '%'. $request->search .'%')->Paginate(15);
            return view('/users', ['user' => $user]);
        }
Comment

Laravel 7 pagination with search filter

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

blade search pagination

Route::any ( '/search', function () {
 $q = Input::get ( 'q' );
 if($q != ""){
 $user = User::where ( 'name', 'LIKE', '%' . $q . '%' )->orWhere ( 'email', 'LIKE', '%' . $q . '%' )->paginate (5)->setPath ( '' );
 $pagination = $user->appends ( array (
    'q' => Input::get ( 'q' ) 
  ) );
 if (count ( $user ) > 0)
  return view ( 'welcome' )->withDetails ( $user )->withQuery ( $q );
 }
  return view ( 'welcome' )->withMessage ( 'No Details found. Try to search again !' );
} );
Comment

PREVIOUS NEXT
Code Example
Php :: laravel request protected prop 
Php :: php post not working 
Php :: php catch fatal error 
Php :: laravel query builder delete all 
Php :: laravel log error 
Php :: debugbar:clear in laravel 
Php :: wpquery search taxonomy 
Php :: send email php form 
Php :: Symmetric encryption in PHP 
Php :: expose loading laravel 
Php :: image not save laravel 
Php :: remove field from object php 
Php :: laravel use npm package 
Php :: laravel automatically encrypt model atribute 
Php :: login form tutorialpoint 
Php :: php base58 decode 
Php :: array map php 
Php :: install multiple php versions windows 
Php :: install php-mysql 
Php :: laravel repository design pattern 
Php :: php interview questions for 2 year experience 
Php :: laravel echo 
Php :: php return multiple variables from function 
Php :: public $baseURL codeigniter 4 
Php :: attach one or multiple files laravel mail 
Php :: get the selected value of dropdown php 
Php :: Basic HTTP Authentication example 
Php :: latest php version 
Php :: laravel crob job in cpanel 
Php :: header in fpdi 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =