コード例 #1
0
 public function saving($model)
 {
     $tmp_model = new \App\Package();
     // RULES
     if (is_array($model->package_ids)) {
         foreach ($model->package_ids as $k => $v) {
             $rules['package_ids' . $k] = ['exists:' . $tmp_model->getTable()];
         }
     } else {
         $rules['package_ids'] = ['exists:' . $tmp_model->getTable()];
     }
     $validator = Validator::make($model->toArray(), $rules);
     if ($validator->fails()) {
         $model->setErrors($validator->messages());
         return false;
     }
 }
コード例 #2
0
 public function saving($model)
 {
     $tmp_model = new \App\Package();
     // RULES
     $rules['package_id'] = ['integer', 'min:1', 'exists:' . $tmp_model->getTable() . ',id'];
     $validator = Validator::make($model->toArray(), $rules);
     if ($validator->fails()) {
         $model->setErrors($validator->messages());
         return false;
     }
 }