Last active
May 17, 2017 21:42
-
-
Save clouddueling/4199789 to your computer and use it in GitHub Desktop.
Fulltext eloquent search with Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
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
I added the 'in boolean mode' for some reason results weren't coming up until I did that.