Example #1
0
 public static function validateFields($fields, $objects, $formpage, $donepage)
 {
     $type = $fields['type'];
     $rules = Product::getAllRules($type);
     // Validate images
     $images = $fields['images'];
     if (count($images) > 0) {
         $validator = self::validateImages($images);
         if ($validator != null) {
             return Redirect::to($formpage)->withErrors($validator);
         }
     }
     // Validate fields
     $validator = Validator::make($fields, $rules);
     if ($validator->fails()) {
         return Redirect::to($formpage)->withErrors($validator);
     } else {
         self::saveToDB($fields, $objects['product'], $objects['rim'], $objects['tire']);
         Session::flash('message', 'Successfully saved product!');
         return Redirect::to($donepage);
     }
 }