| Conditions | 4 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Bedard\Shop\Controllers; |
||
| 18 | public function validate() |
||
| 19 | { |
||
| 20 | $data = input('inventory'); |
||
| 21 | if (! $data || ! is_array($data)) { |
||
| 22 | return Response::make('Error', 422); |
||
| 23 | } |
||
| 24 | |||
| 25 | try { |
||
| 26 | $inventory = Inventory::firstOrNew(['id' => $data['id']]); |
||
| 27 | $inventory->fill($data); |
||
| 28 | $inventory->validate(); |
||
| 29 | } catch (Exception $e) { |
||
| 30 | return Response::make($e->getMessage(), 400); |
||
| 31 | } |
||
| 32 | |||
| 33 | return Response::make($inventory, 200); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |