Laravel Search String

Laravel Search String

Laravel Search String is a package by Loris Leiva that generates database queries based on one unique string using a simple and customizable syntax.

Laravel Search String provides a simple solution for scoping your database queries using a human-readable and customizable syntax. It will transform a simple string into a powerful query builder.

Here’s a nice visual example of what this all means taken from the project’s readme:

Here’s a brief code example that is taken from the readme using the search string and the equivalent query builder:

Article::usingSearchString('title:"My blog article" or not published sort:-created_at');

// Equivalent to:
Article::where('title', 'My blog article')
       ->orWhere('published', false)
       ->orderBy('created_at', 'desc');

Check out the documentation for full details on the extensive search syntax and all the customizations you can make. You can learn more about this package and check out the source code on GitHub at lorisleiva/laravel-search-string.


Filed in: Laravel Packages


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Mid / Sen. Software Engineer
Clearwater, FL
ShineOn
Remote PHP / Laravel Developer
Remote
SpringboardVR
Senior PHP/Laravel Developer: Your Dream Work Environment
Remote
iPhone Photography School
Senior Laravel Developer
Leidseplein, Amsterdam
Orderchamp.com
PHP Developer
Remote
X-Team
Senior Laravel Developer (Canada and India)
London, Ontario, Canada
Factory Bucket Inc.
Laravel, PHP, PostgreSQL, Neo4J Developer
Pune, India (intern in Denver, CO)
Life AI