Download the PHP package asseco-voice/laravel-json-search without Composer

On this page you can find all versions of the php package asseco-voice/laravel-json-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-json-search

Laravel JSON search

This package exposes a jsonSearch method on Laravel Eloquent models providing a detailed DB search with JSON as input parameter.

It functions out-of-the-box automatically for all Eloquent models within the project. No additional setup is needed.

Installation

Install the package through composer. It is automatically registered as a Laravel service provider, so no additional actions are required.

composer require asseco-voice/laravel-json-search

Usage

Package provides few endpoints out of the box:

Model should be provided in standard Laravel notation (lowercase plural) in order to map it automatically (i.e. /api/search/contacts in order to search Contact model).

By default, App namespace is used, but you can change the defaults or add additional endpoints if you have need for that in the package configuration by either adding a direct model mapping in model_mapping key (taking precedence over other options), or adding additional values to models_namespaces array to make it more generic.

Description on how to use each of those are in the configuration file.

If out-of-the-box solutions don't suit you, feel free to implement the logic directly within your controller. For details check out custom endpoints section.

Following are some examples, however there is much more to the search package than just filtering by attributes.

For detailed engine usage and logic, refer to this readme.

Examples

POST

Call the endpoint providing the following JSON:

This will perform a SELECT * FROM some_table WHERE first_name IN ('foo, 'bar') AND first_name not in ('baz') or last_name in ('test').

Additionally, you are able to provide append array to resolve your custom defined properties on a Laravel model which aren't listed in $appends array. I.e.

You can return it by using:

It is possible to do 1-level nested appends like:

More than 1-level is not supported.

Do note that this is completely unoptimized and will potentially cause really slow executions. Use with caution.

PUT

Call the endpoint providing the following JSON:

This will perform a SELECT * FROM some_table WHERE first_name IN ('foo, 'bar') AND first_name not in ('baz') or last_name in ('test'), and on the given result set it will perform a mass update giving a new name to every record retrieved

DELETE

This will perform a DELETE FROM some_table WHERE first_name IN ('foo, 'bar') AND first_name not in ('baz') or last_name in ('test') doing a mass delete by given parameters.

Custom endpoints

It is possible to create a custom endpoint if the current setup does not suit you.

Search

Update

Delete

Search favorites

Favorites enable you to save searches for a specific user.

Usage:

  1. Run php artisan migrate.
  2. Use through standard laravel API resource routes on /api/search-favorites URL.
  3. If you need to modify migrations publish the package and set runs_migrations property in the config file to false.
  4. Set authorizeResource in asseco-search to false if you do not want $this->authorizeResource(SearchFavorite::class) to be added in controller.

It is possible to extend the model used for search favorites and replace with your own. Make sure your model extends SearchFavorite and replace search_favorite_model key in the configuration with your model.

Debugging

If you'd like to see query called instead of a result, uncomment dump line within Asseco\JsonSearch\SearchServiceProvider.

Due to Laravel query builder inner workings, this will not dump the resulting query for relations. For that purpose I'd recommend using Laravel query log.

Extending the package

Publishing the configuration will enable you to change package models as well as controlling how migrations behave. If extending the model, make sure you're extending the original model in your implementation.


All versions of laravel-json-search with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
asseco-voice/laravel-json-query-builder Version ^2.0
laravel/framework Version ^10.0
asseco-voice/laravel-common Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package asseco-voice/laravel-json-search contains the following files

Loading the files please wait ....