Search
 
SCRIPT & CODE EXAMPLE
 

PHP

pagination with search query in laravel

  {{ $products->appends($_GET)->links()}}
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

PREVIOUS NEXT
Code Example
Php :: run queue after x minutes laravel 
Php :: get the user detail inside the constructor Laravel 
Php :: workpress change page title from shortcode 
Php :: install php7 
Php :: while loop laravel 
Php :: how to set 1 year date without saturday in while loop php 
Php :: causes of class not found in laravel 
Php :: laravel show method 
Php :: php slice string by character 
Php :: validate number should by 12 digit in php 
Php :: php xpath attribute exact 
Php :: extend multiple classes in php 
Php :: php unset by value 
Php :: wordpress run php code in page 
Php :: get ids from object 
Php :: rand in codeigniter 
Php :: how to update a table based on three columns laravel 
Php :: Laravel 7 pagination with search filter 
Php :: base64_img 
Php :: php array_pop with key 
Php :: send gmail 
Php :: view blade not found in laravel 
Php :: require password confirm laravel 
Php :: how to run a php file using 
Php :: php pre 
Php :: create table laravel give name table 
Php :: laravel property 
Php :: password_verify 
Php :: sendmail folder missing in xampp 
Php :: symfony functional test clear session and cookies 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =