Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel eloquent search query 2020

$result = Marriage::where('name','LIKE','%'.$email_or_name.'%')
                ->orWhere('email','LIKE','%'.$email_or_name.'%')
                ->get();
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 query in laravel

$searchTerm ='milad zamir Abc';
$reservedSymbols = ['-', '+', '<', '>', '@', '(', ')', '~'];
$searchTerm = str_replace($reservedSymbols, ' ', $searchTerm);

$searchValues = preg_split('/s+/', $searchTerm, -1, PREG_SPLIT_NO_EMPTY);

$res = User::where(function ($q) use ($searchValues) {
	foreach ($searchValues as $value) {
    $q->orWhere('name', 'like', "%{$value}%");
    $q->orWhere('family_name', 'like', "%{$value}%");
    }
})->get();
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

PREVIOUS NEXT
Code Example
Php :: string to double php 
Php :: php mysql insert data 
Php :: convert to int laravel 
Php :: switch case php 
Php :: twig json_encode 
Php :: displaying errors in laravel 
Php :: php get method name 
Php :: upload file in wp from url 
Php :: reverse array laravel 
Php :: change background color php 
Php :: composer remove cache 
Php :: Get PHP Date Time Difference in Days, Hours, Minutes, and Seconds 
Php :: why css not working with php file 
Php :: cut string in php 
Php :: how to start a session 
Php :: usleep php 
Php :: laravel flutter save image in data 
Php :: Wordpress hook for newly published post 
Php :: php get hour 
Php :: twig symfony get route 
Php :: php calculate percentage 
Php :: how to add properties to the request object in laravel 
Php :: php fpm status check 
Php :: laravel route list only api 
Php :: How to use php to set title 
Php :: Laravel Eloquent, group by month/year 
Php :: Internal error: xmlSchemaXPathProcessHistory, The state object to be removed is not the first in the list. 
Php :: include a page from another directory php 
Php :: block direct access to php images 
Php :: header cross origin using php only for our domains and subdomain 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =