Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

Laravel Full Text Search

David Carr

Laravel Framework Tutorials PHP & MySQL

When searching using LIKE search for basic searches is fine, when you need greater control Full-Text searches is far greater.

Laravel does not support Full-Text searches due to it being too MySQL specific. However, it can still be used by using RAW queries

In whereRaw specify MATCH followed by the columns to search then specify AGAINST ? place holder which will be replaced when executes with the values from an array.

Product::whereRaw('MATCH (title, content) AGAINST (?)' , array($search))->get();

In order for this to work, you will need to add Full-Text index against your table columns in MySQL.

DB::statement('ALTER TABLE products ADD FULLTEXT fulltext_index (title, content)');


Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!


My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.