/** * validation state helper * * @param \Illuminate\Support\ViewErrorBag $errors * @param array|string $names * @param string $context * @return string */ function validation_state(Illuminate\Support\ViewErrorBag $errors, $names, $context = 'has-danger') { //normalize input to array if (!is_array($names)) { $names = [$names]; } //check if error exists foreach ($names as $name) { if ($errors->has($name)) { return $context; } } //no error return ''; }
/** * Build the error component. * @param Illuminate\Support\ViewErrorBag $errors * @param string $name * @return string */ protected function buildError($errors, $name) { return '<small class="error">' . $errors->first($name) . '</small>'; }