|
|
@@ -1,30 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-namespace Controllers;
|
|
|
-
|
|
|
-use Libs\ResponseLib;
|
|
|
-use Models\DescriptionModel;
|
|
|
-use Psr\Http\Message\ServerRequestInterface;
|
|
|
-use Respect\Validation\Validator as v;
|
|
|
-use Respect\Validation\Exceptions\ValidationException;
|
|
|
-
|
|
|
-class DescriptionGetController
|
|
|
-{
|
|
|
- public function __invoke(ServerRequestInterface $request)
|
|
|
- {
|
|
|
- $body = json_decode((string) $request->getBody(), true) ?? [];
|
|
|
-
|
|
|
- try {
|
|
|
- v::key('company_id', v::intType()->positive())->assert($body);
|
|
|
- } catch (ValidationException $e) {
|
|
|
- return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
|
|
|
- }
|
|
|
-
|
|
|
- $companyId = (int) $body['company_id'];
|
|
|
-
|
|
|
- $model = new DescriptionModel();
|
|
|
- $data = $model->getDescriptionsByCompany($companyId);
|
|
|
-
|
|
|
- return ResponseLib::sendOk($data);
|
|
|
- }
|
|
|
-}
|