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]);
}
// 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}%");
}
});
}
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]);
}
// 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();
// Employee Model
public function searchResult($search)
{
$query = DB::table("employee") ->where('employee_name', 'LIKE', '%'.$search.'%')->get();
return $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);
// ...
$users = User::has('posts')->withCount('posts')->orderBy('posts_count')->take(50)->get();
$userIndex = $users->search(function($user) {
return $user->id === Auth::id();
});
Code Example |
---|
Php :: php token generator |
Php :: how set field after another field in migration in laravel |
Php :: php find string in string |
Php :: uuid in laravel |
Php :: laravel query by relationship |
Php :: yum install php-mysql |
Php :: compile custom/plain css with mix in laravel |
Php :: laravel composer update |
Php :: php expire a session |
Php :: laravel rule unique ignore |
Php :: laravel loop variable |
Php :: find curren monday in laravel carbon |
Php :: how to check php version in php |
Php :: php get tempfile |
Php :: how validate array in laravel in request |
Php :: eloquent limit vs take |
Php :: php define object |
Php :: php export excel |
Php :: php empty array |
Php :: Larvel Print last query |
Php :: replace php |
Php :: php mysqli fetch single row |
Php :: php get second last element of array |
Php :: laravel session |
Php :: laravel foreach |
Php :: php get first word of string |
Php :: laravel map array |
Php :: laravel username validation |
Php :: print array on php |
Php :: pluck array in laravel |