| @@ 653-670 (lines=18) @@ | ||
| 650 | * @return array $item; |
|
| 651 | * @throws InvalidItemException |
|
| 652 | */ |
|
| 653 | protected function validate($item) |
|
| 654 | { |
|
| 655 | $rules = array( |
|
| 656 | 'id' => 'required', |
|
| 657 | 'price' => 'required|numeric', |
|
| 658 | 'quantity' => 'required|numeric|min:1', |
|
| 659 | 'name' => 'required', |
|
| 660 | ); |
|
| 661 | ||
| 662 | $validator = CartItemValidator::make($item, $rules); |
|
| 663 | ||
| 664 | if ($validator->fails()) { |
|
| 665 | throw new InvalidItemException($validator->messages()->first()); |
|
| 666 | } |
|
| 667 | ||
| 668 | return $item; |
|
| 669 | } |
|
| 670 | ||
| 671 | /** |
|
| 672 | * add row to cart collection |
|
| 673 | * |
|
| @@ 278-293 (lines=16) @@ | ||
| 275 | * @param $args |
|
| 276 | * @throws InvalidConditionException |
|
| 277 | */ |
|
| 278 | protected function validate($args) |
|
| 279 | { |
|
| 280 | $rules = array( |
|
| 281 | 'name' => 'required', |
|
| 282 | 'type' => 'required', |
|
| 283 | 'target' => 'required', |
|
| 284 | 'value' => 'required', |
|
| 285 | ); |
|
| 286 | ||
| 287 | $validator = CartConditionValidator::make($args, $rules); |
|
| 288 | ||
| 289 | if( $validator->fails() ) |
|
| 290 | { |
|
| 291 | throw new InvalidConditionException($validator->messages()->first()); |
|
| 292 | } |
|
| 293 | } |
|
| 294 | ||
| 295 | protected function getConfig() |
|
| 296 | { |
|