From 6950ab8aa52f75f3df1008072b852ffea21af417 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 29 Mar 2017 21:21:14 +0300 Subject: [PATCH] Support searching by client.id_number in the API --- app/Http/Controllers/ClientApiController.php | 3 ++- docs/api.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ClientApiController.php b/app/Http/Controllers/ClientApiController.php index d71fb65761e8..d32968eacbf9 100644 --- a/app/Http/Controllers/ClientApiController.php +++ b/app/Http/Controllers/ClientApiController.php @@ -46,11 +46,12 @@ class ClientApiController extends BaseAPIController ->orderBy('created_at', 'desc') ->withTrashed(); - // Filter by email if ($email = Input::get('email')) { $clients = $clients->whereHas('contacts', function ($query) use ($email) { $query->where('email', $email); }); + } elseif ($idNumber = Input::get('id_number')) { + $clients = $clients->whereIdNumber($idNumber); } return $this->listResponse($clients); diff --git a/docs/api.rst b/docs/api.rst index dee8a67f7d77..ea6b34b62d86 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -25,11 +25,12 @@ For invoices, quotes, tasks and payments simply change the object type. curl -X GET ninja.dev/api/v1/invoices -H "X-Ninja-Token: TOKEN" -You can search clients by their email address and invoices by their invoice number. +You can search clients by their email address or id number and invoices by their invoice number. .. code-block:: shell curl -X GET ninja.dev/api/v1/clients?email= -H "X-Ninja-Token: TOKEN" + curl -X GET ninja.dev/api/v1/clients?id_number= -H "X-Ninja-Token: TOKEN" curl -X GET ninja.dev/api/v1/invoices?invoice_number= -H "X-Ninja-Token: TOKEN" To load a single record specify the Id in the URL.