Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel create search

public function index(){
      // // we need to show all data from "blog" table
      // $blogs = Blog::all();
      // // show data to our view
      // return view('blog.index',['blogs' => $blogs]);

      $search = Request::get('search');
      $blogs = Blog::where('title','like','%'.$search.'%')->orderBy('id')->paginate(6);
      return view('blog.index',['blogs' => $blogs]);
    }
Comment

laravel search query

  // SEARCH QUERY
  if (request()->has('search')){
      $search = trim(request('search'));
      $resumess = $resumess->where(function($query) use ($search){
          $query->where('doc_name', 'LIKE', "%{$search}%");
          $searches = explode(" ",$search);
          foreach($searches as $s){
              $query->orWhere('first_name', 'LIKE', "%{$s}%");
              $query->orWhere('last_name', 'LIKE', "%{$s}%");
              $query->orWhere('position_type', 'LIKE', "%{$s}%");
              $query->orWhere('position_type', 'LIKE', "%{$s}%");
          }
      });
  }
Comment

search in laravel 8

public function index(){
      // // we need to show all data from "blog" table
      // $blogs = Blog::all();
      // // show data to our view
      // return view('blog.index',['blogs' => $blogs]);

      $search = Request::get('search');
      $blogs = Blog::where('title','like','%'.$search.'%')->orderBy('id')->paginate(6);
      return view('blog.index',['blogs' => $blogs]);
    }
Comment

Laravel Search

// Why do this ..
$users=User :: where(function($query)use($value){
    $query->orWhere('name','like',"{$value)")
          ->orWhere('email','like',"{$value}")
          ->orWhere('title','like',"{$value}")
          ->orWhere('role','like',"{$value}%")
          ->orWhere('status','like',"{$value}%")
})->get();
//...when you can do the same with this?
$users User :: search($value)->get();
Comment

search laravel

// Employee Model
public function searchResult($search)
{
  $query = DB::table("employee") ->where('employee_name', 'LIKE', '%'.$search.'%')->get();
  return $query;
}
Comment

laravel search query

public function index()
{
  $q = Dog::query();

  if (Input::has('search'))
  {
     // simple where here or another scope, whatever you like
     $q->where('name','like',Input::get('search'));
  }

  if (Input::has('search-breed'))
  {
     $q->searchBreed(Input::get('search-breed'));
  }

  if (Input::has('sex'))
  {
     $q->where('sex', Input::get('sex'));
  }

  if (Input::has('radius'))
  {
     $q->withinRadius(Input::get('radius'));
  }

  $dogs = $q->orderBy(..)->paginate(5);

  // ...
Comment

laravel search function

$users = User::has('posts')->withCount('posts')->orderBy('posts_count')->take(50)->get();

$userIndex = $users->search(function($user) {
    return $user->id === Auth::id();
});
Comment

PREVIOUS NEXT
Code Example
Php :: install php7 
Php :: Symmetric encryption in PHP 
Php :: decode a nested JSON with php 
Php :: month php written out 
Php :: php dump to page 
Php :: havingraw in laravel 
Php :: Redirect to HTTPS & remove www 
Php :: checkout 
Php :: validate number should by 12 digit in php 
Php :: value() in laravel 
Php :: laravel map the output of the api 
Php :: fixing unclosed html tags 
Php :: laravel get route action 
Php :: how to migrate new column without empty the table in laravel 
Php :: PHP OOP - Inheritance 
Php :: how to use concat in laravel 
Php :: nested loop in php 
Php :: access paginator object attribute in laravel 
Php :: php 8 Match Expression / Switch Case 
Php :: laravel kill current session 
Php :: doctrine where 
Php :: connect to ftp server php 
Php :: status validation laravel 
Php :: connect php to db 
Php :: :: in php 
Php :: Redirect with named route in Laravel 
Php :: run laravel without php artisan serve 
Php :: strip html tag php 
Php :: WooCommerce shop loop random array function not same values after each other 
Php :: Check Data Load More Laravel Livewire 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =