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


PHP MessageBag::first方法代码示例

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


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

示例1: getErrorFor

 /**
  * Get the error for a field, wrapped in a label
  *
  * @param  InputInterface $field
  * @param  string         $id
  * @param  array          $attributes
  *
  * @return string|boolean
  */
 public function getErrorFor(InputInterface $field, $id, array $attributes = array())
 {
     $error = $this->errors->first($field->getName());
     if ($error) {
         return $this->builder->label($id, $error, $attributes);
     }
     return false;
 }
开发者ID:ruysu,项目名称:laravel4-form,代码行数:17,代码来源:FieldCollection.php

示例2: getErrorMessage

 /**
  * @param string $key
  * @return string
  */
 public static function getErrorMessage($key)
 {
     if (isset(self::$_messages)) {
         $message = self::$_messages->first($key);
         $message = $message ?: self::$_messages->first(self::_dotNotation($key));
         return $message;
     }
     return '';
 }
开发者ID:web-feet,项目名称:coasterframework,代码行数:13,代码来源:FormMessage.php

示例3: testFormatIsRespected

 public function testFormatIsRespected()
 {
     $container = new MessageBag();
     $container->setFormat('<p>:message</p>');
     $container->add('foo', 'bar');
     $container->add('boom', 'baz');
     $this->assertEquals('<p>bar</p>', $container->first('foo'));
     $this->assertEquals(array('<p>bar</p>'), $container->get('foo'));
     $this->assertEquals(array('<p>bar</p>', '<p>baz</p>'), $container->all());
     $this->assertEquals('bar', $container->first('foo', ':message'));
     $this->assertEquals(array('bar'), $container->get('foo', ':message'));
     $this->assertEquals(array('bar', 'baz'), $container->all(':message'));
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:13,代码来源:MessageBagTest.php

示例4: fetchMessage

 /**
  * Method to fetch message depending upon it's type
  * @param  MessageBag|string $messages
  * @return string
  */
 protected function fetchMessage($messages)
 {
     if ($messages instanceof MessageBag) {
         return $messages->first();
     } else {
         if (is_string($messages)) {
             return $messages;
         } else {
             return self::MESSAGE;
         }
     }
 }
开发者ID:owlgrin,项目名称:wallet,代码行数:17,代码来源:Exception.php

示例5: first

 /**
  * Check for the key in the error manager session else return the message
  * from the message bag
  *
  * @param  string  $key
  * @param  string  $format
  * @return string
  */
 public function first($key = null, $format = null)
 {
     if ($key) {
         if (Session::has('errorManager.errors')) {
             $errors = new parent(Session::get('errorManager.errors'));
             if ($errors->has($key)) {
                 return $errors->first($key);
             }
         }
     }
     return parent::first($key);
 }
开发者ID:michaeljennings,项目名称:errormanager,代码行数:20,代码来源:ErrorManager.php

示例6: validate

 /**
  * Test if the form values are valid. It will validate each
  * element and add an error to that element if the validation
  * fails.
  *
  * @param Validator $validator
  */
 protected function validate()
 {
     // If there are no errors, then we don't have to do
     // anything more.
     if (!$this->errors) {
         return $this;
     }
     // Add the errors to the elements
     foreach ($this->getElements() as $name => $element) {
         // For now, we only use the first error
         $error = $this->errors->first($name);
         if ($error) {
             $element->withError()->help($error);
         }
     }
 }
开发者ID:boyhagemann,项目名称:form,代码行数:23,代码来源:FormBuilder.php

示例7: getErrorMessage

 public function getErrorMessage($default = '')
 {
     return $this->errors->first('message') ?: $default;
 }
开发者ID:sthWrong,项目名称:season5.co,代码行数:4,代码来源:AbstractRepository.php

示例8: errors

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

示例9: prv_redirect

 /**
  * Construct the redirection
  */
 private function prv_redirect($type, \Illuminate\Support\MessageBag $messagesBag)
 {
     $strMessages = '';
     if ($messagesBag->count() > 1) {
         $strMessages = '<ul>';
         foreach ($messagesBag as $e) {
             $strMessages .= '<li>' . $e . '</li>';
         }
         $strMessages .= '</ul>';
     } else {
         $strMessages = $messagesBag->first();
     }
     Notification::$type($strMessages);
     if ($type == 'error') {
         return $this->mRedirect->withInput()->withErrors($messagesBag);
     } else {
         return $this->mRedirect;
     }
 }
开发者ID:ajgallego,项目名称:laravel-helpers,代码行数:22,代码来源:HelpRedirect.php

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