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


PHP MessageBag::getMessages方法代码示例

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


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

示例1: getErrors

 /**
  * Returns errors from the validator. This will return only messages
  * if the request is from ajax.
  *
  * @return array|\Illuminate\Support\MessageBag
  */
 public function getErrors()
 {
     if (Request::ajax()) {
         return $this->errors->getMessages();
     } else {
         return $this->errors;
     }
 }
开发者ID:redknitin,项目名称:maintenance,代码行数:14,代码来源:BaseValidator.php

示例2: formatErrors

 /**
  * Format the validation errors.
  *
  * @param \Illuminate\Support\MessageBag $errors
  *
  * @return mixed
  */
 protected function formatErrors($errors)
 {
     $output = [];
     foreach ($errors->getMessages() as $field => $message) {
         $output[] = ['code' => 'validation_fails', 'field' => $field, 'message' => isset($message[0]) ? $message[0] : ''];
     }
     return $output;
 }
开发者ID:jenky,项目名称:muzik,代码行数:15,代码来源:ApiValidationException.php

示例3: testFirstReturnsSingleMessage

 public function testFirstReturnsSingleMessage()
 {
     $container = new MessageBag();
     $container->setFormat(':message');
     $container->add('foo', 'bar');
     $container->add('foo', 'baz');
     $messages = $container->getMessages();
     $this->assertEquals('bar', $container->first('foo'));
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:9,代码来源:MessageBagTest.php

示例4: setFlash

 /**
  * Write all alerts to session flash
  */
 public function setFlash()
 {
     $flash = array();
     foreach ($this->bag->getMessages() as $type => $messages) {
         foreach ($messages as $message) {
             $flash[$type][] = $message;
         }
     }
     $this->session->flash(self::SESSION_KEY, $flash);
 }
开发者ID:creolab,项目名称:alert,代码行数:13,代码来源:Environment.php

示例5: getErrors

 /**
  * get all messages from message bag
  * 
  * @param boolean $raw
  * @return mixed
  */
 public function getErrors($raw = false)
 {
     if ($this->errors === null) {
         $this->errors = new MessageBag();
     }
     if ($raw) {
         return $this->errors;
     }
     return $this->errors->getMessages();
 }
开发者ID:yangmls,项目名称:laravel-validation-trait,代码行数:16,代码来源:ValidationTrait.php

示例6: validate

 public function validate($attributes = [])
 {
     /* @var $this Model */
     if (!method_exists($this, 'rules')) {
         return true;
     }
     $attributes = $attributes ? array_merge($this->getAttributes(), $attributes) : $this->getAttributes();
     $validator = Main::$app->connection->validator->make($attributes, $this->rules());
     $result = $validator->passes();
     if (!$result) {
         $this->errors = $validator->errors();
         foreach ($this->errors->getMessages() as $errors) {
             foreach ($errors as $error) {
                 Alert::add($error, Alert::ERROR);
             }
         }
         return false;
     }
     return true;
 }
开发者ID:xandros15,项目名称:aigisu,代码行数:20,代码来源:Validator.php

示例7: render

 /**
  * Show specific alert type
  * @param  string $type
  * @return string
  */
 public function render()
 {
     if ($this->bag->any()) {
         $output = array();
         foreach ($this->bag->getMessages() as $type => $messages) {
             foreach ($messages as $message) {
                 // Prepare output
                 $output[] = array('type' => $type, 'data' => $message);
             }
         }
         //$json = new JsonResponse;
         //return json_encode($output);
         return $output;
     }
 }
开发者ID:hsyngkby,项目名称:result,代码行数:20,代码来源:Result.php

示例8: addCallAnotherErrors

 /**
  * Method to loop through errors and merge them into parent attribute
  * @param string     $attribute
  * @param integer     $index
  * @param MessageBag $errors
  */
 private function addCallAnotherErrors($attribute, MessageBag $errors)
 {
     foreach ($errors->getMessages() as $nestedAttribute => $messages) {
         foreach ($messages as $message) {
             $specifier = $this->makeSpecifier('call_another');
             $specifier = str_replace(':attribute', $attribute, $specifier);
             $this->messages->add($attribute, "{$specifier} {$message}");
         }
     }
 }
开发者ID:owlgrin,项目名称:hive,代码行数:16,代码来源:Validator.php

示例9: validation

 /**
  * Sets a validation error flash message.
  *
  * @param MessageBag $errors
  * @param string $message
  */
 public function validation(MessageBag $errors, $message = 'Form validation failed')
 {
     $this->error($message);
     $this->session->flash('flash_notification.validation', $errors->getMessages());
 }
开发者ID:cybercog,项目名称:gistvote,代码行数:11,代码来源:FlashNotifier.php

示例10: getMessages

 /**
  * Get the raw messages in the message bag.
  *
  * @return array
  */
 public function getMessages()
 {
     return $this->messages->getMessages();
 }
开发者ID:codenest,项目名称:ahem,代码行数:9,代码来源:Notification.php

示例11: mergeErrors

 /**
  * Merge the errors into the multiple form builder.
  *
  * @param MessageBag $errors
  */
 protected function mergeErrors(MessageBag $errors)
 {
     foreach ($errors->getMessages() as $field => $message) {
         $this->builder->addFormError($field, implode('<br>', $message));
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:11,代码来源:HandleErrors.php

示例12: error_422

 /**
  * Validation error.
  *
  * @param  array  $messages
  * @return string
  */
 protected function error_422($messages)
 {
     // Get message bag from validator.
     if ($messages instanceof MessageProviderInterface) {
         $messages = $messages->getMessageBag();
     }
     // Get validation message bag.
     if (!$messages instanceof MessageBag) {
         $messages = new MessageBag($messages);
     }
     $content = array();
     // Re-format error messages.
     foreach ($messages->getMessages() as $field => $message) {
         $error = array('field' => $field, 'message' => current($message));
         array_push($content, $error);
     }
     return $this->make($content, 'error_422');
 }
开发者ID:kossa,项目名称:laravel-restable,代码行数:24,代码来源:Restable.php

示例13: mergeBag

 /**
  * Merge a message bag
  * @param  Illuminate\Support\MessageBag $bag 
  * @return Iyoworks\Support\AlertBag       
  */
 public function mergeBag(MessageBag $bag)
 {
     $this->merge($bag->getMessages());
     return $this;
 }
开发者ID:iyoworks,项目名称:support,代码行数:10,代码来源:AlertBag.php


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