| Conditions | 1 |
| Paths | 1 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function run(Request $request, Response $response, array $args) : Response |
||
| 23 | { |
||
| 24 | // create model |
||
| 25 | $model = new Card(); |
||
| 26 | $model->name = $request->getParsedBodyParam('name', false); |
||
| 27 | |||
| 28 | // validation |
||
| 29 | Card::validators()['name']->assert($model->name); |
||
| 30 | |||
| 31 | // create |
||
| 32 | $model->saveOrFail(); |
||
| 33 | |||
| 34 | // response |
||
| 35 | return $response |
||
| 36 | ->withStatus(201) |
||
| 37 | ->withHeader('Location', sprintf('/cards/%s', $model->id)) |
||
| 38 | ->withJson($model); |
||
| 39 | } |
||
| 40 | } |
||
| 41 |