本文整理汇总了PHP中Illuminate\Support\MessageBag::any方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageBag::any方法的具体用法?PHP MessageBag::any怎么用?PHP MessageBag::any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\MessageBag
的用法示例。
在下文中一共展示了MessageBag::any方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$user = User::findOrFail($id);
$input = Input::only('email', 'first_name', 'last_name', 'role_id', 'confirmed', 'county_id', 'phone', 'school', 'password');
$extra = Input::only('address', 'about');
try {
$in = Input::all();
$in['id'] = $user->id;
$this->editUserForm->validate($in);
} catch (FormValidationException $e) {
$this->errors = $e->getErrors();
}
foreach ($input as $key => $value) {
if (!$this->errors->has($key)) {
if ($key === 'password' && !empty($value)) {
$user->password = $value;
continue;
}
$user->{$key} = $value;
}
}
foreach ($extra as $key => $value) {
if (!$this->errors->has($key)) {
$user->setMeta($key, e($value));
}
}
$user->save();
if ($this->errors->any()) {
return back()->withErrors($this->errors);
}
flash('Modificările au fost salvate cu succes.');
return back();
}
示例2: 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;
}
}
示例3: isValid
/**
* Validate the Model
* runs the validator and binds any errors to the model
*
* @param array $rules
* @param array $messages
* @return bool
*/
public function isValid()
{
$valid = true;
$data = $this->getDirty();
$rules = $this->exists ? $this->getRules($data) : $this->getRules();
if ($rules) {
$validator = Validator::make($data, $rules, $this->getMessages());
$valid = $validator->passes();
}
if (!$valid) {
$this->errorBag = $validator->errors();
} elseif ($this->errorBag && $this->errorBag->any()) {
$this->errorBag = new MessageBag();
}
return $valid;
}
示例4: render
/**
* Show specific alert type
* @param string $type
* @return string
*/
public function render($type = null)
{
if ($this->bag->any()) {
$output = '';
foreach ($this->bag->getMessages() as $type => $messages) {
// Class for opening tag
$class = $type == 'error' ? 'danger' : $type;
// Start collection
$output .= $this->config->get('alert::collection_open', '<div class="alert alert-' . $class . '">') . PHP_EOL;
foreach ($messages as $message) {
// Prepare output
$output .= $this->config->get('alert::alert_open', '<p>');
$output .= $message;
$output .= $this->config->get('alert::alert_close', '</p>');
}
// Close it
$output .= $this->config->get('alert::collection_close', '</div>') . PHP_EOL;
}
return $output;
}
}
示例5: 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');
}
示例6: 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');
}