-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchController.php
More file actions
51 lines (46 loc) · 1.38 KB
/
SearchController.php
File metadata and controls
51 lines (46 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace App\Controller\Data\VYV;
use App\Helper\Api;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
/**
* Search helps you to find user from multiple criteria
*/
class SearchController extends AbstractController
{
private $request;
private $api;
private $data;
/**
* CredentialController constructor.
* @param Api $api
*/
public function __construct(Api $api)
{
$this->request = Request::createFromGlobals();
$this->api = $api;
$this->data = [
'organisation' => 'Vyv',
'controller' => 'AssureController',
'action' => ''
];
}
/**
* @param $searchValue mixed User(details)
* @return JsonResponse
* @api /searchs/insured
* @method POST
* @example Get a list of insured from sending value (e.g Mobile, Name, City, etc...)
*/
public function insured()
{
$this->data['action'] = 'list';
if (!$this->request->isMethod('POST'))
throw new MethodNotAllowedException(['POST'], 'Unallowed method...');
$this->data['search'] = $_POST['searchValue'];
$result = $this->api->get($this->data);
return $this->json($result);
}
}