當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。