“Laravel 8 pencarian dengan pagination” Kode Jawaban

Pagination dengan permintaan pencarian di Laravel

  {{ $products->appends($_GET)->links()}}
Fancy Falcon

pagination laravel dengan filter pencarian

// 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);
Alemhar

Laravel 8 pencarian dengan 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(\Illuminate\Http\Request $request){
        $searchKey = $request->search;
        $contacts = Contact::where("name","LIKE","%$searchKey%")->orWhere("phone","LIKE","%$searchKey%")->paginate(5);
        return view('contact.index',compact('contacts'));
    }


WinMaw

Laravel 7 pagination dengan filter pencarian

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

Laravel Search and Return Record dengan 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]);
        }
Xenophobic Xenomorph

Jawaban yang mirip dengan “Laravel 8 pencarian dengan pagination”

Pertanyaan yang mirip dengan “Laravel 8 pencarian dengan pagination”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya