当前位置: 首页>>代码示例>>PHP>>正文


PHP MessageBag::has方法代码示例

本文整理汇总了PHP中Illuminate\Support\MessageBag::has方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageBag::has方法的具体用法?PHP MessageBag::has怎么用?PHP MessageBag::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\MessageBag的用法示例。


在下文中一共展示了MessageBag::has方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: label

 /**
  * Create a form label element.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  array   $options
  * @return string
  */
 public function label($name, $value = null, $options = array())
 {
     if ($this->validationErrors && $this->validationErrors->has($name)) {
         $options = $this->addClass($options, $this->errorCssClass);
     }
     return parent::label($name, $value, $options);
 }
开发者ID:wingsline,项目名称:inuitcss,代码行数:15,代码来源:FormBuilder.php

示例2: testHasIndicatesExistence

 public function testHasIndicatesExistence()
 {
     $container = new MessageBag();
     $container->setFormat(':message');
     $container->add('foo', 'bar');
     $this->assertTrue($container->has('foo'));
     $this->assertFalse($container->has('bar'));
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:8,代码来源:MessageBagTest.php

示例3: getErrorClass

 /**
  * @param string $key
  * @return string
  */
 public static function getErrorClass($key)
 {
     if (isset(self::$_messages)) {
         $hasErrors = self::$_messages->has($key);
         $hasErrors = $hasErrors ?: self::$_messages->has(self::_dotNotation($key));
         if ($hasErrors) {
             return isset(self::$_errorClass) ? self::$_errorClass : config('coaster::frontend.form_error_class');
         }
     }
     return '';
 }
开发者ID:web-feet,项目名称:coasterframework,代码行数:15,代码来源:FormMessage.php

示例4: shouldStopValidating

 /**
  * Stop on error if "bail" rule is assigned and attribute has a message.
  *
  * @param  string  $attribute
  * @return bool
  */
 protected function shouldStopValidating($attribute)
 {
     if (!$this->hasRule($attribute, ['Bail'])) {
         return false;
     }
     return $this->messages->has($attribute);
 }
开发者ID:imydou,项目名称:dkuu,代码行数:13,代码来源:Validator.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $user = User::findOrFail($id);
     $input = Input::only('email', 'first_name', 'last_name', 'role_id', 'confirmed', 'county_id', 'phone', 'school', 'password');
     $extra = Input::only('address', 'about');
     try {
         $in = Input::all();
         $in['id'] = $user->id;
         $this->editUserForm->validate($in);
     } catch (FormValidationException $e) {
         $this->errors = $e->getErrors();
     }
     foreach ($input as $key => $value) {
         if (!$this->errors->has($key)) {
             if ($key === 'password' && !empty($value)) {
                 $user->password = $value;
                 continue;
             }
             $user->{$key} = $value;
         }
     }
     foreach ($extra as $key => $value) {
         if (!$this->errors->has($key)) {
             $user->setMeta($key, e($value));
         }
     }
     $user->save();
     if ($this->errors->any()) {
         return back()->withErrors($this->errors);
     }
     flash('Modificările au fost salvate cu succes.');
     return back();
 }
开发者ID:adriancatalinsv,项目名称:fiip,代码行数:39,代码来源:UserController.php

示例6: shouldStopValidating

 /**
  * Check if we should stop further validations on a given attribute.
  *
  * @param  string  $attribute
  * @return bool
  */
 protected function shouldStopValidating($attribute)
 {
     if ($this->hasRule($attribute, ['Bail'])) {
         return $this->messages->has($attribute);
     }
     if (isset($this->failedRules[$attribute]) && in_array('uploaded', array_keys($this->failedRules[$attribute]))) {
         return true;
     }
     // In case the attribute has any rule that indicates that the field is required
     // and that rule already failed then we should stop validation at this point
     // as now there is no point in calling other rules with this field empty.
     return $this->hasRule($attribute, $this->implicitRules) && isset($this->failedRules[$attribute]) && array_intersect(array_keys($this->failedRules[$attribute]), $this->implicitRules);
 }
开发者ID:hannesvdvreken,项目名称:framework,代码行数:19,代码来源:Validator.php

示例7: update

 /**
  * @return \Response
  */
 public function update()
 {
     $input = Input::only('email', 'first_name', 'last_name', 'phone', 'school');
     $extra = Input::only('address', 'about');
     try {
         $this->accountForm->validate(Input::all());
     } catch (FormValidationException $e) {
         $this->errors = $e->getErrors();
     }
     foreach ($input as $key => $value) {
         if (!$this->errors->has($key)) {
             $this->user()->{$key} = e(trim($value));
         }
     }
     foreach ($extra as $key => $value) {
         if (!$this->errors->has($key)) {
             $this->user()->setMeta($key, e(trim($value)));
         }
     }
     $this->user()->save();
     return json($this->errors->isEmpty() ? trans('app.saved') : ['errors' => $this->errors]);
 }
开发者ID:adriancatalinsv,项目名称:fiip,代码行数:25,代码来源:AccountController.php

示例8: hasNotFailedPreviousRuleIfPresenceRule

 /**
  * Determine if it's a necessary presence validation.
  *
  * This is to avoid possible database type comparison errors.
  *
  * @param  string  $rule
  * @param  string  $attribute
  * @return bool
  */
 protected function hasNotFailedPreviousRuleIfPresenceRule($rule, $attribute)
 {
     return in_array($rule, ['Unique', 'Exists']) ? !$this->messages->has($attribute) : true;
 }
开发者ID:edwardricardo,项目名称:zenska,代码行数:13,代码来源:Validator.php

示例9: group

 /**
  * Create a form group element.
  *
  * @param string                         $name
  * @param \Illuminate\Support\MessageBag $errors
  * @param string                         $class
  *
  * @return string
  */
 protected function group($name, $errors = null, $class = 'form-group')
 {
     $return = '<div class="' . $class;
     if ($errors && $errors->has($name)) {
         $return .= ' has-error';
     }
     $return .= '">' . "\n";
     return $return;
 }
开发者ID:illuminate3,项目名称:bootawesome,代码行数:18,代码来源:BootstrapBase.php

示例10: hasError

 /**
  * Return whether a field has errors or not.
  *
  * @return bool
  */
 public function hasError($fieldName)
 {
     return $this->errors->has($fieldName);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:9,代码来源:Form.php

示例11: hasError

 /**
  * Check if session in parent class has error
  *
  * @param  string $name
  *
  * @return bool
  */
 private function hasError($name = null)
 {
     return $this->local_errors->has($name);
 }
开发者ID:stolz,项目名称:laravel-form-builder,代码行数:11,代码来源:Foundation.php

示例12: hasErrors

 /**
  * Return is has errror
  *
  * @return boolean
  */
 public function hasErrors()
 {
     return $this->error->has();
 }
开发者ID:jarick,项目名称:bx,代码行数:9,代码来源:FormTrait.php

示例13: group

 /**
  * Create a form group element.
  *
  * @param string                         $name
  * @param \Illuminate\Support\MessageBag $errors
  * @param string                         $class
  * @param array                          $options
  *
  * @return string
  */
 protected function group($name, $errors = null, $class = 'form-group', array $options = array())
 {
     $options = array_merge(array('class' => $class), $options);
     $options['class'] .= $errors && $errors->has($name) ? ' has-error' : '';
     $return = '<div' . $this->html->attributes($options) . '>' . "\n";
     return $return;
 }
开发者ID:jamalapriadi,项目名称:sia,代码行数:17,代码来源:BootstrapBase.php

示例14: select

 /**
  * Create a select box field.
  *
  * @param  string  $name
  * @param  array   $list
  * @param  string  $selected
  * @param  array   $options
  * @return string
  */
 public function select($name, $list = array(), $selected = null, $options = array())
 {
     $selected = $this->getValueAttribute($name, $selected);
     $options['id'] = $this->getIdAttribute($name, $options);
     if (!isset($options['name'])) {
         $options['name'] = $name;
     }
     // The form-control class should be a default class for every input
     // generated. The class option on the input also overrides every
     // default classes set.
     if (isset($options['class'])) {
         $this->setClass($options['class']);
     }
     $options['class'] = "form-control " . $this->class;
     // Removes keys for the wrapper from the $options array and puts them
     // into variables to prevent them from appearing as attributes on the
     // input itself.
     array_key_exists('label', $options) ? $label = array_pull($options, 'label') : ($label = null);
     $html = array();
     foreach ($list as $value => $display) {
         $html[] = $this->getSelectOption($display, $value, $selected);
     }
     // Once we have all of this HTML, we can join this into a single element after
     // formatting the attributes into an HTML "attributes" string, then we will
     // build out a final select statement, which will contain all the values.
     $options = $this->html->attributes($options);
     $list = implode('', $html);
     // Sets the $input variable to the newly generated input field, this
     // variable will then be used within the Bootstrap wrapper instead of
     // being returned directly.
     $input = "<select{$options}>{$list}</select>";
     // If there are errors we want to add the has-error class to the form-group
     // tag to make the border glow red.
     if (!is_null($this->errors) && $this->errors->has($name) && $name != NULL) {
         $this->formGroupClass .= " has-error";
         // If exteded feedback is also enabled we will also add the has-feedback
         // class to allow showing the icons.
         if ($this->feedback === true) {
             $this->formGroupClass .= " has-feedback";
         }
     }
     // The return variable holds the HTML output that is returned to the user.
     // It's purposely divided into lines to allow for better reading and
     // easier conditionals for some of the output.
     $return = '<div class="form-group ' . $this->formGroupClass . '">';
     $return .= '<div class="row">';
     $return .= '<div class="col-md-4">';
     // If a label is given then we show the label here. Notice
     // that the form class is available as IlluminateFormBuilder
     // and not as Form.
     if (!is_null($label)) {
         $return .= IlluminateFormBuilder::label($name, $label);
     }
     $return .= '</div>';
     $return .= '<div class="col-md-8 text-right">';
     // If errors are present we show the error message here.
     // Error styling can be done using the validation-error
     // class that is added automatically.
     if (!is_null($this->errors) && $this->errors->has($name) && $name != NULL) {
         $return .= $this->errors->first($name, '<p class="text-danger validation-error">:message</p>');
     }
     $return .= '</div>';
     $return .= '</div>';
     $return .= $input;
     $return .= '</div>';
     $this->resetConfig();
     return $return;
 }
开发者ID:YammYcoding,项目名称:BootstrapForm,代码行数:77,代码来源:BootstrapForm.php


注:本文中的Illuminate\Support\MessageBag::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。