Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/divineomega/laravel-natural-where
Laravel Natural Where extends the Laravel query builder to allow expressing of where operators in natural language.
https://github.com/divineomega/laravel-natural-where
database eloquent laravel natural-language queries where
Last synced: 18 days ago
JSON representation
Laravel Natural Where extends the Laravel query builder to allow expressing of where operators in natural language.
- Host: GitHub
- URL: https://github.com/divineomega/laravel-natural-where
- Owner: DivineOmega
- Created: 2019-11-22T20:45:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-28T10:27:25.000Z (5 months ago)
- Last Synced: 2024-10-15T02:37:48.826Z (about 1 month ago)
- Topics: database, eloquent, laravel, natural-language, queries, where
- Language: PHP
- Homepage:
- Size: 24.4 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel Natural Where
Laravel Natural Where extends the Laravel query builder to allow expressing of
where operators in natural language.## Installation
To install Laravel Natural Where, run the following command from the
root of your project.```bash
composer require divineomega/laravel-natural-where
```## Usage
See the basic usage example below.
```php
$query = \App\User::query()
->naturalWhere('created_at', 'is between the years', ['2018', '2020'])
->naturalWhere('email', 'contains the word', 'jordan')
->naturalWhere('name', 'is not', 'Jordan Smith')
->naturalWhere('id', 'is one of the following', [1, 2, 3])
->get();
```This example will produce the following SQL query.
```sql
select * from `users` where (`created_at` >= '2018' and `created_at` <= '2020')
and `email` LIKE '%jordan%' and `name` != 'Jordan Smith' and `id` in (1, 2, 3)
```