public function saving($model) { $tag_model = new \App\Tag(); // RULES if (is_array($model->tag_ids)) { foreach ($model->tag_ids as $k => $v) { $rules['tag_ids' . $k] = ['exists:' . $tag_model->getTable()]; } } else { $rules['tag_ids'] = ['exists:' . $tag_model->getTable()]; } $validator = Validator::make($model->toArray(), $rules); if ($validator->fails()) { $model->setErrors($validator->messages()); return false; } }