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