Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Last active May 17, 2017 21:42
Show Gist options
  • Save clouddueling/4199789 to your computer and use it in GitHub Desktop.
Save clouddueling/4199789 to your computer and use it in GitHub Desktop.
Fulltext eloquent search with Laravel
public static function read_search($terms, $limit = 20)
{
$contact_results = Contact::where_account_user_id(Auth::user()->account_user_id)
->where_deleted(0)
->where_marketing(0)
->where_mass_merge(0)
->raw_where("match (`first`, `last`) against (?)", array($terms))
->take($limit)
->get();
return $contact_results;
}
@clouddueling
Copy link
Author

I added the 'in boolean mode' for some reason results weren't coming up until I did that.

@clouddueling
Copy link
Author

This now does a fulltext search maintaing the Eloquent relationships!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment