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


PHP Event::getValidationRules方法代码示例

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


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

示例1: rules

 /**
  * Get the validation rules that apply to the request.
  * @return array
  */
 public function rules()
 {
     return Event::getValidationRules('name', 'em_id', 'type', 'description', 'venue', 'venue_type', 'client_type', 'date_start', RequestFacade::has('one_day') ? '' : 'date_end', 'time_start', 'time_end');
 }
开发者ID:backstagetechnicalservices,项目名称:website,代码行数:8,代码来源:EventRequest.php

示例2: update_UpdateDetails

 /**
  * Update the event's venue
  * @param \App\Http\Requests\GenericRequest $request
  * @param \App\Event                        $event
  * @return mixed
  */
 private function update_UpdateDetails(GenericRequest $request, Event $event)
 {
     // Check a field is specified
     $field = $request->get('field') ?: @key($request->except('_token'));
     $value = $request->get('value') ?: $request->get($field);
     if (!$field) {
         return $this->ajaxError('Invalid submission');
     }
     // Check if the field is the em id
     if ($field == 'em_id' && !$this->user->isAdmin()) {
         return $this->ajaxError('You need to be an admin to change the EM');
     }
     // Perform some checks on the value based on the event type
     if (!$event->isEvent() && in_array($field, ['client_type', 'venue_type'])) {
         $value = null;
     }
     // Validate
     $validator = Validator::make([$field => $value], Event::getValidationRules($field), Event::getValidationMessages($field));
     if ($validator->fails()) {
         if (!$request->get('field')) {
             $this->throwValidationException($request, $validator);
         } else {
             return $this->ajaxError($validator->messages()->first());
         }
     }
     // Send email if the EM has been set
     if ($field == 'em_id' && $value != $event->em_id && $value) {
         $user = User::find($value);
         Mail::queue('emails.events.new_em', ['event' => $event->name, 'event_id' => $event->id, 'user' => $user->forename], function ($message) use($user) {
             $message->to($user->email, $user->name)->subject('Volunteered to EM event');
         });
     }
     // Update
     $event->update([$field => $value]);
     if (!$request->get('field')) {
         Flash::success('Updated');
     }
     return Response::json(true);
 }
开发者ID:backstagetechnicalservices,项目名称:website,代码行数:45,代码来源:EventsController.php


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