https://github.com/boadusamuel/searchnestedjsoncolumn
To search for nested json column in a database without case sensitivity
https://github.com/boadusamuel/searchnestedjsoncolumn
Last synced: 11 months ago
JSON representation
To search for nested json column in a database without case sensitivity
- Host: GitHub
- URL: https://github.com/boadusamuel/searchnestedjsoncolumn
- Owner: boadusamuel
- Created: 2022-10-22T18:27:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-22T20:54:25.000Z (over 3 years ago)
- Last Synced: 2025-02-27T23:11:34.664Z (over 1 year ago)
- Language: PHP
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Search Nested JSON Database Column
This package enables you make search inside nested json column in a database without case sensitivity inside laravel projects.
## Installation
You can install the package via composer:
```composer require boadusamuel/search-nested-json-column ```
## Usage
After installing the package, you can use the trait in your model like so:
```
use Boadusamuel\SearchNestedJsonColumn\SearchNestedJsonColumn;
class Product extends Model { use SearchNestedJsonColumn; }
```
Then you can use the search method like so:
```
Product::query()->when($search, function (Builder $query) use ($search) {
$this->searchJsonColumn($query, 'attribute_data->name->value->en', $search);
})->get();
```
Where `attribute_data` is the json column and `name->value->en` is the nested column you want to search.
Also `$search` is the value you want to search for and `$this` referring to the model with the `SearchNestedJsonColumn` trait.