本文整理汇总了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');
}
示例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);
}