bakaphp /
phalcon-api
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Gewaer\Api\Controllers; |
||
| 6 | |||
| 7 | use Phalcon\Http\Response; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Class BaseController |
||
| 11 | * |
||
| 12 | * @package Gewaer\Api\Controllers |
||
| 13 | * @property Users $userData |
||
| 14 | * |
||
| 15 | */ |
||
| 16 | abstract class BaseCustomFieldsController extends \Baka\Http\Rest\CrudCustomFieldsController |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Get Uer |
||
| 20 | * |
||
| 21 | * @param mixed $id |
||
| 22 | * |
||
| 23 | * @method GET |
||
| 24 | * @url /v1/company/{id} |
||
| 25 | * |
||
| 26 | * @return Response |
||
| 27 | */ |
||
| 28 | 2 | public function getById($id) : Response |
|
| 29 | { |
||
| 30 | //find the info |
||
| 31 | 2 | $company = $this->model->findFirst([ |
|
| 32 | 2 | 'id = ?0 AND is_deleted = 0 and users_id = ?1', |
|
| 33 | 2 | 'bind' => [$id, $this->userData->getId()], |
|
| 34 | ]); |
||
| 35 | |||
| 36 | //get relationship |
||
| 37 | 2 | if ($this->request->hasQuery('relationships')) { |
|
| 38 | $relationships = $this->request->getQuery('relationships', 'string'); |
||
| 39 | |||
| 40 | $company = QueryParser::parseRelationShips($relationships, $company); |
||
|
0 ignored issues
–
show
|
|||
| 41 | } |
||
| 42 | |||
| 43 | 2 | if ($company) { |
|
| 44 | 2 | return $this->response($company->toFullArray()); |
|
| 45 | } else { |
||
| 46 | throw new UnprocessableEntityHttpException('Record not found'); |
||
|
0 ignored issues
–
show
The type
Gewaer\Api\Controllers\U...ableEntityHttpException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Add a new item |
||
| 52 | * |
||
| 53 | * @method POST |
||
| 54 | * @url /v1/company |
||
| 55 | * |
||
| 56 | * @return Response |
||
| 57 | */ |
||
| 58 | 2 | public function create() : Response |
|
| 59 | { |
||
| 60 | 2 | $request = $this->request->getPost(); |
|
| 61 | |||
| 62 | 2 | if (empty($request)) { |
|
| 63 | $request = $this->request->getJsonRawBody(true); |
||
| 64 | } |
||
| 65 | |||
| 66 | //transaction |
||
| 67 | 2 | $this->db->begin(); |
|
| 68 | |||
| 69 | //alwasy overwrite userid |
||
| 70 | 2 | $request['users_id'] = $this->userData->getId(); |
|
| 71 | |||
| 72 | 2 | $this->model->setCustomFields($request); |
|
| 73 | //try to save all the fields we allow |
||
| 74 | 2 | if ($this->model->save($request, $this->createFields)) { |
|
| 75 | 2 | $this->db->commit(); |
|
| 76 | 2 | return $this->response($this->model->findFirst($this->model->getId())->toFullArray()); |
|
| 77 | } else { |
||
| 78 | $this->db->rollback(); |
||
| 79 | throw new UnprocessableEntityHttpException((string) $this->model->getMessages()[0]); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | } |
||
| 83 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths