Laravel Rest Api now supports Laravel Scout

With the latest release of Laravel Rest Api, the quick and easy way to manage your Api in Laravel, a native integration of Laravel Scout has been released.

Now, just by specifying "search.text.value" in your search, you are able to make a full text search from your front-end side:

// (POST) api/posts/search
{
    "text": {
        "value": "my full text search"
    }
}

Fully integrates with other Laravel Rest Api features

By using full text search you have some small limitations on the arguments you can provide but this doesn`t restrict other features which allow you to perform the following query :

// (POST) api/posts/search
{
    "text": {
        "value": "my full text search"
    },
    "filters": [
        {
            "field": "type", "operator": "=", "value": "romance"
        }
    ],
    "sorts": [
        {"field": "user_id", "direction": "desc"},
        {"field": "id", "direction": "asc"}
    ],
    "selects": [
        {"field": "id"}
    ],
    "includes": [
        {
            "relation": "posts",
            "filters": [
                 {"field": "id", "operator": "in", "value": [1, 3]}
            ],
            "limit": 2
        },
        {
            "relation": "user",
            "filters": [
                {
                    "field": "languages.pivot.boolean",
                    "operator": "=",
                    "value": true
                }
            ]
        }
    ],
    "aggregates": [
        {
            "relation": "stars",
            "type": "max",
            "field": "rate",
            "filters": [
                {"field": "approved", "value": true}
            ]
        }
    ],
    "instructions": [
      {
        "name": "odd-even-id",
        "fields": [
          { "name": "type", "value": "odd" }
        ]
      }
    ],
    "page": 2,
    "limit": 10
}

Links

The Laravel Rest Api package and documentation can be found on GitHub at lomkit/laravel-rest-api.


The post Laravel Rest Api now supports Laravel Scout appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.