| Conditions | 2 |
| Paths | 7 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Bedard\Shop\Controllers; |
||
| 19 | public function create() |
||
| 20 | { |
||
| 21 | try { |
||
| 22 | // create our new option |
||
| 23 | $option = input('option'); |
||
| 24 | unset($option['id']); |
||
| 25 | $model = Option::create($option); |
||
| 26 | $model->load('values'); |
||
| 27 | |||
| 28 | // attach it to the product with a deferred binding |
||
| 29 | $product = new Product; |
||
| 30 | $product->options()->add($model, uniqid('session_key', true)); |
||
| 31 | |||
| 32 | // return the new option |
||
| 33 | return Response::make($model, 200); |
||
| 34 | } catch (Exception $e) { |
||
| 35 | // if anything went wrong, send back the error message |
||
| 36 | return Response::make($e->getMessage(), 500); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 59 |