Commit ad0d01784376ad665e1a261ee9a355dcd5a52bcb
1 parent
e8cab5b7
test
Showing
1 changed file
with
19 additions
and
4 deletions
Show diff stats
app/library/App/Controllers/UserController.php
| @@ -62,10 +62,25 @@ class UserController extends CrudResourceController | @@ -62,10 +62,25 @@ class UserController extends CrudResourceController | ||
| 62 | 62 | ||
| 63 | $data = $this->transformPostData($data); | 63 | $data = $this->transformPostData($data); |
| 64 | 64 | ||
| 65 | - $user = new User(); | ||
| 66 | - $user->name = $data['name']; | ||
| 67 | - $user->pass = $data['pass']; | ||
| 68 | - $user->save(); | 65 | +// $user = new User(); |
| 66 | +// $user->name = $data['name']; | ||
| 67 | +// $user->pass = $data['pass']; | ||
| 68 | +// $user->save(); | ||
| 69 | + | ||
| 70 | + $item = $this->createModelInstance(); | ||
| 71 | + | ||
| 72 | + $newItem = $this->createItem($item, $data); | ||
| 73 | + | ||
| 74 | + if (!$newItem) { | ||
| 75 | + return $this->onCreateFailed($item, $data); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + $primaryKey = $this->getModelPrimaryKey(); | ||
| 79 | + $responseData = $this->getFindData($newItem->$primaryKey); | ||
| 80 | + | ||
| 81 | + $response = $this->getCreateResponse($responseData, $data); | ||
| 82 | + | ||
| 83 | + return $response; | ||
| 69 | 84 | ||
| 70 | } | 85 | } |
| 71 | 86 |