Download the PHP package algolia/laravel-scout-algolia-macros without Composer

On this page you can find all versions of the php package algolia/laravel-scout-algolia-macros. 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-scout-algolia-macros

DEPRECATED: Use of this repository is deprecated. Please use Scout Extended - https://github.com/algolia/scout-extended instead.

Laravel Scout Algolia Macros

A collection of useful macros to extend Laravel Scout capabilities when using the Algolia engine.

This package aims to provide a set of macros to take advantage of the Algolia-specific feature.

Installation

Pull the package using composer

Next, you should add the Algolia\ScoutMacros\ServiceProvider to the providers array of your config/app.php configuration file:

Usage

count

The count method will return the number of results after the request to Algolia.

The point is to avoid pull data from the database and building the collection.

hydrate

The hydrate method is similar to the standard get() method, except it hydrates the models from your Algolia index.

By default, Scout will use the IDs of the results from Algolia and pull the data from the local database to create the collection.

Hence, hydrate will be much faster than get.

Note: By using this method you must be sure that you are correctly keeping your algolia index in sync with your database to avoid populating stale data.

Restrict attributes

By default, this method will add all attributes from Algolia's record to your model. If you want to remove sensitive or irrelevant data from your model, you have two options.

You can set a list of retrievable attributes in your Algolia dashboard. In this case, Algolia will only return these attributes while still searching every searchableAttributes.

You may as well use the laravel $guarded attributes of your model class. For instance, if you don't want to see the _h attribute in your collection, you will have the following.

with

The with method gives you complete access to the Algolia options parameter. This allows you to customise the search parameters exactly the same as you would using the algolia php library directly.

Simple example

Advanced example

aroundLatLng

ThearoundLatLng method will add geolocation parameter to the search request. You can define a point with its coordinate.

Note that this method is pure syntactic sugar, you can use with to specify more location details (like radius for instance)

Where clauses can also be added

Contributing

Feel free to open an issue to request a macro.

Open any pull request you want, so we can talk about it and improve the package. :tada:


All versions of laravel-scout-algolia-macros with dependencies

PHP Build Version
Package Version
Requires laravel/scout Version 3.0.5 || ~4.0 || ~5.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 algolia/laravel-scout-algolia-macros contains the following files

Loading the files please wait ....