Page Contents

FilteringΒΆ

JSON API Filtering allow searching your API and requires:

  1. Composer installing friendsofcake/search
  2. Configuring the Crud SearchListener as described here

Now create search aliases named filter in your tables like shown below:

// src/Model/Table/CountriesTable.php

public function searchManager()
{
    $searchManager = $this->behaviors()->Search->searchManager();
    $searchManager->like('filter', [
        'before' => true,
        'after' => true,
        'field' => [$this->aliasField('name')],
    ]);

    return $searchManager;
}

Once that is done you will be able to search your API using URLs similar to:

  • /countries?filter=netherlands
  • /countries?filter=nether
  v: latest
Versions
latest
stable
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds
Downloads
On GitHub
View
Edit

Free document hosting provided by Read the Docs.