public function getSearch()
    {
        if (!userHasPermission('admin:invoice:invoice:manage')) {
            throw new ApiException('You are not authorised to search invoices.', 401);
        }

        $oInput        = Factory::service('Input');
        $sKeywords     = $oInput->get('keywords');
        $oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');

        if (strlen($sKeywords) >= 3) {
            throw new ApiException('Search term must be 3 characters or longer.', 400);
        }

        $oResult = $oInvoiceModel->search($sKeywords, null, null, ['expand' => ['customer']]);
        $aOut    = [];

        foreach ($oResult->data as $oInvoice) {
            $aOut[] = $this->formatInvoice($oInvoice);
        }

        return Factory::factory('ApiResponse', 'nails/module-api')
                      ->setData($aOut);
    }