{"id":13828305,"url":"https://github.com/lorisleiva/laravel-search-string","last_synced_at":"2025-05-15T04:05:31.175Z","repository":{"id":32440751,"uuid":"133257772","full_name":"lorisleiva/laravel-search-string","owner":"lorisleiva","description":"🔍 Generates database queries based on one unique string","archived":false,"fork":false,"pushed_at":"2024-03-13T13:01:00.000Z","size":297,"stargazers_count":780,"open_issues_count":8,"forks_count":50,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-05-08T13:03:02.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lorisleiva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["lorisleiva"]}},"created_at":"2018-05-13T17:06:49.000Z","updated_at":"2025-03-30T20:22:06.000Z","dependencies_parsed_at":"2022-08-25T11:20:14.753Z","dependency_job_id":"e5be319d-872f-49d1-b42b-fc5ee5d8a3c1","html_url":"https://github.com/lorisleiva/laravel-search-string","commit_stats":{"total_commits":182,"total_committers":8,"mean_commits":22.75,"dds":0.09340659340659341,"last_synced_commit":"3842079d0fe6315a3a24dbc30c15ed590c635357"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorisleiva%2Flaravel-search-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorisleiva%2Flaravel-search-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorisleiva%2Flaravel-search-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorisleiva%2Flaravel-search-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lorisleiva","download_url":"https://codeload.github.com/lorisleiva/laravel-search-string/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227585,"owners_count":22035664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:02:40.627Z","updated_at":"2025-05-15T04:05:26.154Z","avatar_url":"https://github.com/lorisleiva.png","language":"PHP","funding_links":["https://github.com/sponsors/lorisleiva"],"categories":["PHP"],"sub_categories":[],"readme":"# 🔍 Laravel Search String\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/lorisleiva/laravel-search-string.svg)](https://packagist.org/packages/lorisleiva/laravel-search-string)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/lorisleiva/laravel-search-string/Tests?label=tests)](https://github.com/lorisleiva/laravel-search-string/actions?query=workflow%3ATests+branch%3Anext)\n[![Total Downloads](https://img.shields.io/packagist/dt/lorisleiva/laravel-search-string.svg)](https://packagist.org/packages/lorisleiva/laravel-search-string)\n\nGenerates database queries based on one unique string using a simple and customizable syntax.\n\n![Example of a search string syntax and its result](https://user-images.githubusercontent.com/3642397/40266921-6f7b4c70-5b54-11e8-8e40-000ae3b4e201.png)\n\n\n## Introduction\n\nLaravel 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.\n\nFor example, the following search string will fetch the latest blog articles that are either not published or titled \"My blog article\".\n\n```php\nArticle::usingSearchString('title:\"My blog article\" or not published sort:-created_at');\n\n// Equivalent to:\nArticle::where('title', 'My blog article')\n       -\u003eorWhere('published', false)\n       -\u003eorderBy('created_at', 'desc');\n```\n\nThis next example will search for the term \"John\" on the `customer` and `description` columns whilst making sure the invoices are either paid or archived.\n\n```php\nInvoice::usingSearchString('John and status in (Paid,Archived) limit:10 from:10');\n\n// Equivalent to:\nInvoice::where(function ($query) {\n           $query-\u003ewhere('customer', 'like', '%John%')\n               -\u003eorWhere('description', 'like', '%John%');\n       })\n       -\u003ewhereIn('status', ['Paid', 'Archived'])\n       -\u003elimit(10)\n       -\u003eoffset(10);\n```\n\nYou can also query for the existence of related records, for example, articles published in 2020, which have more than 100 comments that are either not spam or written by John.\n\n```php\nArticle::usingSearchString('published = 2020 and comments: (not spam or author.name = John) \u003e 100');\n\n// Equivalent to:\nArticle::where('published_at', '\u003e=', '2020-01-01 00:00:00')\n        -\u003ewhere('published_at', '\u003c=', '2020-12-31 23:59:59')\n        -\u003ewhereHas('comments', function ($query) {\n            $query-\u003ewhere('spam', false)\n                -\u003eorWhereHas('author' function ($query) {\n                    $query-\u003ewhere('name', 'John');\n                });\n        }, '\u003e', 100);\n```\n\nAs you can see, not only it provides a convenient way to communicate with your Laravel API (instead of allowing dozens of query fields), it also can be presented to your users as a tool to explore their data.\n\n## Installation\n\n```bash\n# Install via composer\ncomposer require lorisleiva/laravel-search-string\n\n# (Optional) Publish the search-string.php configuration file\nphp artisan vendor:publish --tag=search-string\n```\n\n## Basic usage\n\nAdd the `SearchString` trait to your models and configure the columns that should be used within your search string.\n\n```php\nuse Lorisleiva\\LaravelSearchString\\Concerns\\SearchString;\n\nclass Article extends Model\n{\n    use SearchString;\n\n    protected $searchStringColumns = [\n        'title', 'body', 'status', 'rating', 'published', 'created_at',\n    ];\n}\n```\n\nNote that you can define these in [other parts of your code](#other-places-to-configure) and [customise the behaviour of each column](#configuring-columns).\n\nThat's it! Now you can create a database query using the search string syntax.\n\n```php\nArticle::usingSearchString('title:\"Hello world\" sort:-created_at,published')-\u003eget();\n```\n\n## The search string syntax\n\nNote that the spaces between operators don't matter.\n\n### Exact matches\n\n```php\n'rating: 0'\n'rating = 0'\n'title: Hello'               // Strings without spaces do not need quotes\n'title: \"Hello World\"'       // Strings with spaces require quotes\n\"title: 'Hello World'\"       // Single quotes can be used too\n'rating = 99.99'\n'created_at: \"2018-07-06 00:00:00\"'\n```\n\n### Comparisons\n\n```php\n'title \u003c B'\n'rating \u003e 3'\n'created_at \u003e= \"2018-07-06 00:00:00\"'\n```\n\n### Lists\n\n```php\n'title in (Hello, Hi, \"My super article\")'\n'status in(Finished,Archived)'\n'status:Finished,Archived'\n```\n\n### Dates\n\nThe column must either be cast as a date or explicitly marked as a date in the [column options](#date).\n\n```php\n// Year precision\n'created_at \u003e= 2020'                    // 2020-01-01 00:00:00 \u003c= created_at\n'created_at \u003e 2020'                     // 2020-12-31 23:59:59 \u003c created_at\n'created_at = 2020'                     // 2020-01-01 00:00:00 \u003c= created_at \u003c= 2020-12-31 23:59:59\n'not created_at = 2020'                 // created_at \u003c 2020-01-01 00:00:00 and created_at \u003e 2020-12-31 23:59:59\n\n// Month precision\n'created_at = 01/2020'                  // 2020-01-01 00:00:00 \u003c= created_at \u003c= 2020-01-31 23:59:59\n'created_at \u003c= \"Jan 2020\"'              // created_at \u003c= 2020-01-31 23:59:59\n'created_at \u003c 2020-1'                   // created_at \u003c 2020-01-01 00:00:00\n\n// Day precision\n'created_at = 2020-12-31'               // 2020-12-31 00:00:00 \u003c= created_at \u003c= 2020-12-31 23:59:59\n'created_at \u003e= 12/31/2020\"'             // 2020-12-31 23:59:59 \u003c= created_at\n'created_at \u003e \"Dec 31 2020\"'            // 2020-12-31 23:59:59 \u003c created_at\n\n// Hour and minute precisions\n'created_at = \"2020-12-31 16\"'          // 2020-12-31 16:00:00 \u003c= created_at \u003c= 2020-12-31 16:59:59\n'created_at = \"2020-12-31 16:30\"'       // 2020-12-31 16:30:00 \u003c= created_at \u003c= 2020-12-31 16:30:59\n'created_at = \"Dec 31 2020 5pm\"'        // 2020-12-31 17:00:00 \u003c= created_at \u003c= 2020-12-31 17:59:59\n'created_at = \"Dec 31 2020 5:15pm\"'     // 2020-12-31 17:15:00 \u003c= created_at \u003c= 2020-12-31 17:15:59\n\n// Exact precision\n'created_at = \"2020-12-31 16:30:00\"'    // created_at = 2020-12-31 16:30:00\n'created_at = \"Dec 31 2020 5:15:10pm\"'  // created_at = 2020-12-31 17:15:10\n\n// Relative dates\n'created_at = today'                    // today between 00:00 and 23:59\n'not created_at = today'                // any time before today 00:00 and after today 23:59\n'created_at \u003e= tomorrow'                // from tomorrow at 00:00\n'created_at \u003c= tomorrow'                // until tomorrow at 23:59\n'created_at \u003e tomorrow'                 // from the day after tomorrow at 00:00\n'created_at \u003c tomorrow'                 // until today at 23:59\n```\n\n### Booleans\n\nThe column must either be cast as a boolean or explicitly marked as a boolean in the [column options](#boolean).\n\nAlternatively, if the column is marked as a date, it will automatically be marked as a boolean using `is null` and `is not null`.\n\n```php\n'published'         // published = true\n'created_at'        // created_at is not null\n```\n\n### Negations\n\n```php\n'not title:Hello'\n'not title=\"My super article\"'\n'not rating:0'\n'not rating\u003e4'\n'not status in (Finished,Archived)'\n'not published'     // published = false\n'not created_at'    // created_at is null\n```\n\n### Null values\n\nThe term `NULL` is case sensitive.\n\n```php\n'body:NULL'         // body is null\n'not body:NULL'     // body is not null\n```\n\n### Searchable\n\nAt least one column must be [defined as searchable](#searchable-1).\n\nThe queried term must not match a boolean column, otherwise it will be handled as a boolean query.\n\n```php\n'Apple'             // %Apple% like at least one of the searchable columns\n'\"John Doe\"'        // %John Doe% like at least one of the searchable columns\n'not \"John Doe\"'    // %John Doe% not like any of the searchable columns\n```\n\n### And/Or\n\n```php\n'title:Hello body:World'        // Implicit and\n'title:Hello and body:World'    // Explicit and\n'title:Hello or body:World'     // Explicit or\n'A B or C D'                    // Equivalent to '(A and B) or (C and D)'\n'A or B and C or D'             // Equivalent to 'A or (B and C) or D'\n'(A or B) and (C or D)'         // Explicit nested priority\n'not (A and B)'                 // Equivalent to 'not A or not B'\n'not (A or B)'                  // Equivalent to 'not A and not B'\n```\n\n### Relationships\n\nThe column must be explicitly [defined as a relationship](#relationship) and the model associated with this relationship must also use the `SearchString` trait.\n\nWhen making a nested query within a relationship, Laravel Search String will use the column definition of the related model.\n\nIn the following examples, `comments` is a `HasMany` relationship and `author` is a nested `BelongsTo` relationship within the `Comment` model.\n\n```php\n// Simple \"has\" check\n'comments'                              // Has comments\n'not comments'                          // Doesn't have comments\n'comments = 3'                          // Has 3 comments\n'not comments = 3'                      // Doesn't have 3 comments\n'comments \u003e 10'                         // Has more than 10 comments\n'not comments \u003c= 10'                    // Same as before\n'comments \u003c= 5'                         // Has 5 or less comments\n'not comments \u003e 5'                      // Same as before\n\n// \"WhereHas\" check\n'comments: (title: Superbe)'            // Has comments with the title \"Superbe\"\n'comments: (not title: Superbe)'        // Has comments whose titles are different than \"Superbe\"\n'not comments: (title: Superbe)'        // Doesn't have comments with the title \"Superbe\"\n'comments: (quality)'                   // Has comments whose searchable columns match \"%quality%\"\n'not comments: (spam)'                  // Doesn't have comments marked as spam\n'comments: (spam) \u003e= 3'                 // Has at least 3 spam comments\n'not comments: (spam) \u003e= 3'             // Has at most 2 spam comments\n'comments: (not spam) \u003e= 3'             // Has at least 3 comments that are not spam\n'comments: (likes \u003c 5)'                 // Has comments with less than 5 likes\n'comments: (likes \u003c 5) \u003c= 10'           // Has at most 10 comments with less than 5 likes\n'not comments: (likes \u003c 5)'             // Doesn't have comments with less than 5 likes\n'comments: (likes \u003e 10 and not spam)'   // Has non-spam comments with more than 10 likes\n\n// \"WhereHas\" shortcuts\n'comments.title: Superbe'               // Same as 'comments: (title: Superbe)'\n'not comments.title: Superbe'           // Same as 'not comments: (title: Superbe)'\n'comments.spam'                         // Same as 'comments: (spam)'\n'not comments.spam'                     // Same as 'not comments: (spam)'\n'comments.likes \u003c 5'                    // Same as 'comments: (likes \u003c 5)'\n'not comments.likes \u003c 5'                // Same as 'not comments: (likes \u003c 5)'\n\n// Nested relationships\n'comments: (author: (name: John))'      // Has comments from the author named John\n'comments.author: (name: John)'         // Same as before\n'comments.author.name: John'            // Same as before\n\n// Nested relationships are optimised\n'comments.author.name: John and comments.author.age \u003e 21'   // Same as: 'comments: (author: (name: John and age \u003e 21))\n'comments.likes \u003e 10 or comments.author.age \u003e 21'           // Same as: 'comments: (likes \u003e 10 or author: (age \u003e 21))\n```\n\nNote that all these expressions delegate to the `has` query method. Therefore, it works out-of-the-box with the following relationship types: `HasOne`, `HasMany`, `HasOneThrough`, `HasManyThrough`, `BelongsTo`, `BelongsToMany`, `MorphOne`, `MorphMany` and `MorphToMany`.\n\nThe only relationship type currently not supported is `MorphTo` since Laravel Search String needs an explicit related model to use withing nested queries.\n\n### Special keywords\n\nNote that these keywords [can be customised](#configuring-special-keywords).\n\n```php\n'fields:title,body,created_at'  // Select only title, body, created_at\n'not fields:rating'             // Select all columns but rating\n'sort:rating,-created_at'       // Order by rating asc, created_at desc\n'limit:1'                       // Limit 1\n'from:10'                       // Offset 10\n```\n\n## Configuring columns\n\n### Column aliases\n\nIf you want a column to be queried using a different name, you can define it as a key/value pair where the key is the database column name and the value is the alias you wish to use.\n\n```php\nprotected $searchStringColumns = [\n    'title',\n    'body' =\u003e 'content',\n    'published_at' =\u003e 'published',\n    'created_at' =\u003e 'created',\n];\n```\n\nYou can also provide a regex pattern for a more flexible alias definition.\n\n```php\nprotected $searchStringColumns = [\n    'published_at' =\u003e '/^(published|live)$/',\n    // ...\n];\n```\n\n### Column options\n\nYou can configure a column even further by assigning it an array of options.\n\n```php\nprotected $searchStringColumns = [\n    'created_at' =\u003e [\n        'key' =\u003e 'created',         // Default to column name: /^created_at$/\n        'date' =\u003e true,             // Default to true only if the column is cast as date.\n        'boolean' =\u003e true,          // Default to true only if the column is cast as boolean or date.\n        'searchable' =\u003e false       // Default to false.\n        'relationship' =\u003e false     // Default to false.\n        'map' =\u003e ['x' =\u003e 'y']       // Maps data from the user input to the database values. Default to [].\n    ],\n    // ...\n];\n```\n\n#### Key\nThe `key` option is what we've been configuring so far, i.e. the alias of the column. It can be either a regex pattern (therefore allowing multiple matches) or a regular string for an exact match.\n\n#### Date\nIf a column is marked as a `date`, the value of the query will be parsed using `Carbon` whilst keeping the level of precision given by the user. For example, if the `created_at` column is marked as a `date`:\n\n```php\n'created_at \u003e= tomorrow' // Equivalent to:\n$query-\u003ewhere('created_at', '\u003e=', 'YYYY-MM-DD 00:00:00');\n// where `YYYY-MM-DD` matches the date of tomorrow.\n\n'created_at = \"July 6, 2018\"' // Equivalent to:\n$query-\u003ewhere('created_at', '\u003e=', '2018-07-06 00:00:00');\n      -\u003ewhere('created_at', '\u003c=', '2018-07-06 23:59:59');\n```\n\nBy default any column that is cast as a date (using Laravel properties), will be marked as a date for LaravelSearchString. You can force a column to not be marked as a date by assigning `date` to `false`.\n\n#### Boolean\nIf a column is marked as a `boolean`, it can be used with no operator or value. For example, if the `paid` column is marked as a `boolean`:\n\n```php\n'paid' // Equivalent to:\n$query-\u003ewhere('paid', true);\n\n'not paid' // Equivalent to:\n$query-\u003ewhere('paid', false);\n```\n\nIf a column is marked as both `boolean` and `date`, it will be compared to `null` when used as a boolean. For example, if the `published_at` column is marked as `boolean` and `date` and uses the `published` alias:\n\n```php\n'published' // Equivalent to:\n$query-\u003ewhereNotNull('published');\n\n'not published_at' // Equivalent to:\n$query-\u003ewhereNull('published');\n```\n\nBy default any column that is cast as a boolean or as a date (using Laravel properties), will be marked as a boolean. You can force a column to not be marked as a boolean by assigning `boolean` to `false`.\n\n#### Searchable\nIf a column is marked as `searchable`, it will be used to match search queries, i.e. terms that are alone but are not booleans like `Apple Banana` or `\"John Doe\"`.\n\nFor example if both columns `title` and `description` are marked as `searchable`:\n\n```php\n'Apple Banana' // Equivalent to:\n$query-\u003ewhere(function($query) {\n          $query-\u003ewhere('title', 'like', '%Apple%')\n                -\u003eorWhere('description', 'like', '%Apple%');\n      })\n      -\u003ewhere(function($query) {\n          $query-\u003ewhere('title', 'like', '%Banana%')\n                -\u003eorWhere('description', 'like', '%Banana%');\n      });\n\n'\"John Doe\"' // Equivalent to:\n$query-\u003ewhere(function($query) {\n          $query-\u003ewhere('title', 'like', '%John Doe%')\n                -\u003eorWhere('description', 'like', '%John Doe%');\n      });\n```\n\nIf no searchable columns are provided, such terms or strings will be ignored.\n\n#### Relationship\n\nIf a column is marked as a `relationship`, it will be used to query relationships.\n\nThe column name must match a valid relationship method on the model but, as usual, aliases can be created using the [`key` option](#key).\n\nThe model associated with that relationship method must also use the `SearchString` trait in order to nest relationship queries.\n\nFor example, say you have an Article Model and you want to query its related comments. Then, there must be a valid `comments` relationship method and the `Comment` model must itself use the `SearchString` trait.\n\n```php\nuse Lorisleiva\\LaravelSearchString\\Concerns\\SearchString;\n\nclass Article extends Model\n{\n    use SearchString;\n\n    protected $searchStringColumns = [\n        'comments' =\u003e [\n            'key' =\u003e '/^comments?$/',   // aliases the column to `comments` or `comment`.\n            'relationship' =\u003e true,     // There must be a `comments` method that defines a relationship.\n        ],\n    ];\n\n    public function comments()\n    {\n        return $this-\u003ehasMany(Comment::class);\n    }\n}\n\nclass Comment extends Model\n{\n    use SearchString;\n\n    protected $searchStringColumns = [\n        // ...\n    ];\n}\n```\n\nNote that, since Laravel Search String is simply delegating to the `$builder-\u003ehas(...)` method, you can provide any fancy relationship method you want and the constraints will be kept. For example:\n\n```php\nprotected $searchStringColumns = [\n    'myComments' =\u003e [\n        'key' =\u003e 'my_comments',\n        'relationship' =\u003e true,\n    ],\n];\n\npublic function myComments()\n{\n    return $this-\u003ehasMany(Comment::class)-\u003ewhere('author_id', Auth::user()-\u003eid);\n}\n```\n\n## Configuring special keywords\n\nYou can customise the name of a keyword by defining a key/value pair within the `$searchStringKeywords` property.\n\n```php\nprotected $searchStringKeywords = [\n    'select' =\u003e 'fields',   // Updates the selected query columns\n    'order_by' =\u003e 'sort',   // Updates the order of the query results\n    'limit' =\u003e 'limit',     // Limits the number of results\n    'offset' =\u003e 'from',     // Starts the results at a further index\n];\n```\n\nSimilarly to column values you can provide an array to define a custom `key` of the keyword. Note that the `date`, `boolean`, `searchable` and `relationship` options are not applicable for keywords.\n\n```php\nprotected $searchStringKeywords = [\n    'select' =\u003e [\n        'key' =\u003e 'fields',\n    ],\n    // ...\n];\n```\n\n## Other places to configure\n\nAs we've seen so far, you can configure your columns and special keywords using the `searchStringColumns` and `searchStringKeywords` properties on your model.\n\nYou can also override the `getSearchStringOptions` method on your model which defaults to:\n\n```php\npublic function getSearchStringOptions()\n{\n    return [\n        'columns' =\u003e $this-\u003esearchStringColumns ?? [],\n        'keywords' =\u003e $this-\u003esearchStringKeywords ?? [],\n    ];\n}\n```\n\nIf you'd rather not define any of these configurations on the model itself, you can define them directly on the `config/search-string.php` file like this:\n\n```php\n// config/search-string.php\nreturn [\n    'default' =\u003e [\n        'keywords' =\u003e [ /* ... */ ],\n    ],\n\n    Article::class =\u003e [\n        'columns'  =\u003e [ /* ... */ ],\n        'keywords' =\u003e [ /* ... */ ],\n    ],\n];\n```\n\nWhen resolving the options for a particular model, LaravelSearchString will merge those configurations in the following order:\n1. First using the configurations defined on the model\n2. Then using the config file at the key matching the model class\n3. Then using the config file at the `default` key\n4. Finally using some fallback configurations\n\n## Configuring case insensitive searches\n\nWhen using databases like PostgreSql, you can override the default behavior of case sensitive searches by setting case_insensitive to true in your options amongst columns and keywords. For example, in the config/search-string.php\n\n```php\nreturn [\n    'default' =\u003e [\n        'case_insensitive' =\u003e true, // \u003c- Globally.\n        // ...\n    ],\n\n    Article::class =\u003e [\n        'case_insensitive' =\u003e true, // \u003c- Only for the Article class.\n        // ...\n    ],\n];\n```\n\nWhen set to true, it will lowercase both the column and the value before comparing them using the like operator.\n\n```\n$value = mb_strtolower($value, 'UTF8');\n$query-\u003ewhereRaw(\"LOWER($column) LIKE ?\", [\"%$value%\"]);\n```\n\n\n## Error handling\n\nThe provided search string can be invalid for numerous reasons.\n- It does not comply to the search string syntax\n- It tries to query an inexisting column or column alias\n- It provides invalid values to special keywords like `limit`\n- Etc.\n\nAny of those errors will throw an `InvalidSearchStringException`.\n\nHowever you can choose whether you want these exceptions to bubble up to the Laravel exception handler or whether you want them to fail silently. For that, you need to choose a fail strategy on your `config/search-string.php` configuration file:\n\n```php\n// config/search-string.php\nreturn [\n    'fail' =\u003e 'all-results', // (Default) Silently fail with a query containing everything.\n    'fail' =\u003e 'no-results',  // Silently fail with a query containing nothing.\n    'fail' =\u003e 'exceptions',  // Throw exceptions.\n\n    // ...\n];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florisleiva%2Flaravel-search-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Florisleiva%2Flaravel-search-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florisleiva%2Flaravel-search-string/lists"}