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


PHP MessageBag::toArray方法代码示例

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


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

示例1: messagesInfo

 /**
  * Get the message container for the validator.
  *  错误信息是数组格式
  * @return \Illuminate\Support\MessageBag
  */
 public function messagesInfo()
 {
     if (!$this->messages) {
         $this->passes();
     }
     return $this->messages->toArray();
 }
开发者ID:453111208,项目名称:bbc,代码行数:12,代码来源:validator.php

示例2: response

 /**
  * Returns response for browser
  */
 public function response($redirect = null)
 {
     if ($this->request->ajax() || $this->request->wantsJson()) {
         return new JsonResponse(['formErrors' => $this->messageBag->toArray()], 422);
     }
     return \Redirect::to($redirect)->withErrors($this->messageBag->toArray());
 }
开发者ID:gralosky,项目名称:forms,代码行数:10,代码来源:AbstractForm.php

示例3: getErrors

 /**
  * Get the errors attribute
  * @param boolean toArray
  *
  * @return mixed
  */
 public function getErrors($toArray = false)
 {
     if ($toArray) {
         return $this->errors->toArray();
     } else {
         return $this->errors;
     }
 }
开发者ID:agandra,项目名称:amp,代码行数:14,代码来源:Reply.php

示例4: upload

 public function upload(Request $request, Bus $bus, Receiver $receiver, Events $events, MessageBag $messageBag)
 {
     try {
         return $receiver->receive(function ($destination) use($request, $bus) {
             $name = $request->input('flowFilename');
             $description = ['name' => $name, 'path' => $destination, 'title' => $name, 'alt' => $name, 'caption' => $name, 'description' => $name, 'storage' => config('filesystems.default'), 'visibility' => config('inoplate.media.library.default_visibility', 'public'), 'is_moved' => false];
             $userId = $request->user()->id;
             $bus->dispatch(new Commands\CreateNewLibrary($userId, $description));
             $uploaded = $this->libraryRepository->findByPath($destination);
             return $this->formSuccess(route('media.admin.libraries.update.get', ['id' => $uploaded->id()->value()]), ['message' => trans('inoplate-media::messages.library.created'), 'library' => $this->generateReturnedData($uploaded->toArray())]);
         });
     } catch (Exceptions\MaximumUploadSizeExceededException $e) {
         $events->fire(new FileWasFailedToUpload($e->getUploadedFiles()));
         $messageBag->add('file', trans('inoplate-media::messages.library.file_too_large', ['size' => config('inoplate.media.library.size.max') . 'M']));
         return $this->formError(422, $messageBag->toArray());
     } catch (Exceptions\UnallowedFileExtensionException $e) {
         $events->fire(new FileWasFailedToUpload($e->getUploadedFiles()));
         $meta = $e->getLibraryMeta();
         $messageBag->add('file', trans('inoplate-media::messages.library.invalid_extension', ['extension' => $meta['extension']]));
         return $this->formError(422, $messageBag->toArray());
     }
 }
开发者ID:inoplate,项目名称:media,代码行数:22,代码来源:LibraryController.php

示例5: getErrors

 /**
  * Return the errors as an array
  *
  * @param  string $filter
  * @return array
  */
 public function getErrors($filter = null)
 {
     // Create an array to hold errors
     $messages = [];
     // If we have no errors, abort
     if (!$this->errors->count()) {
         return $messages;
     }
     foreach ($this->errors->toArray() as $key => $error) {
         $messages[$key] = $this->extractErrors($error);
     }
     // Return a specific set of messages if asked
     return array_get($messages, $filter);
 }
开发者ID:lakedawson,项目名称:vocal,代码行数:20,代码来源:Vocal.php

示例6: store

 /**
  * 作成処理
  *
  * @param WorkDiaryStoreRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(WorkDiaryStoreRequest $request)
 {
     $errors = new MessageBag();
     DB::transaction(function () use($request, &$errors) {
         $fieldIds = (array) $request->input('field_ids');
         $workFields = WorkField::whereIn('id', $fieldIds)->lockForUpdate()->get();
         if (!WorkField::whereIn('id', $fieldIds)->hasActiveDiary()->get()->isEmpty()) {
             // 編集中日誌のある圃場が選択されている
             $errors->add('field_ids', message('others_update'));
             DB::rollBack();
             return;
         }
         foreach ($workFields as $workField) {
             // 日誌を作成
             $workDiary = new WorkDiary();
             $workDiary->crop_id = $request->get('crop_id');
             $workDiary->work_field_id = $workField->id;
             $workDiary->archive = false;
             $workDiary->fill($request->all());
             $workDiary->save();
         }
     });
     if ($errors->any()) {
         return $this->buildFailedValidationResponse($request, $errors->toArray());
     }
     return redirect()->route('workDiary.index')->with('complete', 'store');
 }
开发者ID:nana4rider,项目名称:mdiary,代码行数:33,代码来源:WorkDiaryController.php

示例7: store

 /**
  * 作成処理
  *
  * @param WorkRecordStoreRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(WorkRecordStoreRequest $request)
 {
     $cropId = $request->input('crop_id');
     $errors = new MessageBag();
     DB::transaction(function () use($request, $cropId, &$errors) {
         $workId = $request->input('work_id');
         $workDiaryIds = (array) $request->input('work_diary_ids');
         $work = Work::findOrFail($workId);
         $workDiaries = WorkDiary::whereIn('id', $workDiaryIds)->lockForUpdate()->get();
         if ($workDiaries->count() !== $workDiaries->where('crop_id', $cropId)->where('archive', false)->count()) {
             // 不正な作業日誌が選択されている
             $errors->add('work_diary_ids', message('others_update'));
             DB::rollBack();
             return;
         }
         // 作業記録登録
         $workRecord = new WorkRecord();
         $workRecord->fill($request->all());
         $workRecord->work_id = $workId;
         $workRecord->crop_id = $cropId;
         // use_complete=falseの場合は常にtrue
         $workRecord->complete = !$work->use_complete || $request->has('complete');
         $workRecord->save();
         // 防除記録
         if ($work->use_pest_control) {
             $sessionPesticides = session()->get('workRecord.pesticides');
             $pesticideIds = $sessionPesticides->keys();
             $pesticides = Pesticide::whereIn('id', $pesticideIds)->whereHas('crops', function ($query) use($cropId) {
                 $query->where('crop_id', $cropId);
             });
             if ($pesticideIds->count() !== $pesticides->count()) {
                 // 農薬の選択が不正
                 $errors->add('pesticide', message('others_update'));
                 DB::rollBack();
                 return;
             }
             foreach ($sessionPesticides as $sessionPesticide) {
                 $workPestControl = new WorkPestControl();
                 $workPestControl->work_record_id = $workRecord->id;
                 $workPestControl->pesticide_id = $sessionPesticide->get('pesticide_id');
                 $workPestControl->usage = $sessionPesticide->get('usage');
                 $workPestControl->save();
             }
         }
         // 播種/定植記録
         if ($work->use_seeding) {
             $workSeeding = new WorkSeeding();
             $workSeeding->work_record_id = $workRecord->id;
             $workSeeding->cultivar_id = $request->input('cultivar_id');
             $workSeeding->fill($request->all());
             $workSeeding->save();
         }
         // 日誌紐付け
         $workRecord->workDiaries()->attach($workDiaryIds);
     });
     if ($errors->any()) {
         return $this->buildFailedValidationResponse($request, $errors->toArray());
     }
     // 農薬情報をクリア
     session()->forget('workRecord.pesticides');
     return redirect()->route('workRecord.index', ['crop_id' => $cropId])->with('complete', 'store');
 }
开发者ID:nana4rider,项目名称:mdiary,代码行数:68,代码来源:WorkRecordController.php

示例8: toArray

 /**
  * Get the instance as an array.
  *
  * @return array
  */
 public function toArray()
 {
     return array('id' => $this->id, 'type' => $this->type, 'settings' => $this->settings, 'heading' => $this->heading, 'messages' => $this->messages->toArray());
 }
开发者ID:codenest,项目名称:ahem,代码行数:9,代码来源:Notification.php

示例9: failure_validate

 protected function failure_validate(\Illuminate\Support\MessageBag $messagebag)
 {
     $errors = $messagebag->toArray();
     $messages = [];
     foreach ($errors as $lines) {
         foreach ($lines as $message) {
             $messages[] = trans(Lang::has('validation.failure_post.list') ? 'validation.failure_post.list' : 'core::common.validation.failure_post.list', compact('message'));
         }
     }
     return $this->_make_output('failure', 'validation.failure_post', FALSE, ['errors' => $errors, 'messages' => implode($messages)], TRUE);
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:11,代码来源:Controller.php

示例10: responseException

 /**
  * Response exception message and code
  *
  * @param $e
  *
  * @return \Illuminate\Http\JsonResponse
  */
 protected function responseException($e)
 {
     $messageBag = new MessageBag();
     $messageBag->add('exception', $e->getMessage());
     return Response::json($messageBag->toArray(), $e->getCode());
 }
开发者ID:schalkt,项目名称:scharest,代码行数:13,代码来源:RestfulTraitController.php


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