laravel eloquent search query 2020
$result = Marriage::where('name','LIKE','%'.$email_or_name.'%')
->orWhere('email','LIKE','%'.$email_or_name.'%')
->get();
laravel eloquent search query 2020
$result = Marriage::where('name','LIKE','%'.$email_or_name.'%')
->orWhere('email','LIKE','%'.$email_or_name.'%')
->get();
search laravel
relationship
$user = User::with('Profile')->where('status', 1)->whereHas('Profile', function($q){
$q->where('gender', 'Male');
})->get();
$searchText = 'test text';
Product::with('owner')->where(function($query) use ($searchText)
{
$query->where('product_name', 'LIKE', '%' . $searchText . '%');
$columns = ['product_code', 'place_location', 'remark'];
foreach ($columns as $column ) {
$query->orWhere($column, 'LIKE', '%' . $searchText . '%');
}
$query->orWhereHas('owner', function($q) use ($searchText) {
$q->where(function($q) use ($searchText) {
$q->where('name', 'LIKE', '%' . $searchText . '%');
$q->orWhere('company_name', 'LIKE', '%' . $searchText . '%');
});
});
});
$comments = Comment::query()->orderby('created_at', 'DESC');
if (!empty($id)){
$comments = $comments->where('id', $request->input('id') );
}
if (!empty($name)){
$comments = $comments->whereHas('author', function ($query) use ($name) { $query-
>where('username', 'like', $name.'%'); });
}
$comment = $comments->paginate(10);
->whereHas('Category', function($query) use($q){
$query->where('name', 'LIKE', '%'. $q .'%')
})->paginate(1)->setPath('');
search laravel
// Employee Model
public function searchResult($search)
{
$query = DB::table("employee") ->where('employee_name', 'LIKE', '%'.$search.'%')->get();
return $query;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us