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


PHP Request::getValidatorInstance方法代码示例

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


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

示例1: getValidatorInstance

 /**
  * Manipulate the input before performing validation
  *
  * @return Validator;
  */
 protected function getValidatorInstance()
 {
     // Set default values.
     collect(['project_id', 'estimatedDuration', 'start', 'minutes'])->each(function ($field) {
         if ($field === 'start') {
             $value = sprintf('%s %s', $this->input($field . 'Date', ''), $this->input($field . 'Time', ''));
             $value = new Carbon($value);
         }
         if ($field === 'project_id') {
             $value = $this->input($field, 0);
         }
         if ($field === 'estimatedDuration') {
             $value = $this->input($field, 0);
         }
         if ($field === 'minutes') {
             $value = 0;
             $start = $this->input('startTime', 0);
             $end = $this->input('endTime', 0);
             if ($start && $end) {
                 $value = (strtotime($end) - strtotime($start)) / 60;
             }
         }
         $this->merge([$field => $value]);
     });
     return parent::getValidatorInstance();
 }
开发者ID:lovett,项目名称:toils,代码行数:31,代码来源:TimeRequest.php

示例2: getValidatorInstance

 /**
  * Overrides getValidatorInstance so we can apply sometimes function
  * @return 
  */
 protected function getValidatorInstance()
 {
     //todo: change validator to handle categories correctly
     return parent::getValidatorInstance();
     //$validator->sometimes('dob', 'valid_date', function($input));
     //return $validator;
 }
开发者ID:ebuckthal,项目名称:gym-bud-laravel,代码行数:11,代码来源:RedpointCompetitionRequest.php

示例3: getValidatorInstance

 protected function getValidatorInstance()
 {
     /*
     	Automatic generate slug
     */
     $this->merge(['slug' => turkish_slug($this->input('title'))]);
     return parent::getValidatorInstance();
 }
开发者ID:AmirHome,项目名称:CMS_20160115,代码行数:8,代码来源:UpdatePagesRequest.php

示例4: getValidatorInstance

 /**
  * Manipulate the input before performing validation
  *
  * @return Validator;
  */
 protected function getValidatorInstance()
 {
     // Set default values.
     collect(['active', 'billable', 'taxDeducted'])->each(function ($field) {
         $value = $this->input($field, 0);
         $this->merge([$field => $value]);
     });
     return parent::getValidatorInstance();
 }
开发者ID:lovett,项目名称:toils,代码行数:14,代码来源:ProjectRequest.php

示例5: getValidatorInstance

 protected function getValidatorInstance()
 {
     $validator = parent::getValidatorInstance();
     $validator->after(function () use($validator) {
         $input = $this->all();
         //	dd($input);
         $this->validateTaskMember($this, $validator);
         $this->validateSubtasks($input['subtasks'], $validator);
     });
     return $validator;
 }
开发者ID:ehomeuc,项目名称:ehome,代码行数:11,代码来源:CreateTaskRequest.php

示例6: getValidatorInstance

 protected function getValidatorInstance()
 {
     $validator = parent::getValidatorInstance();
     $validator->after(function () use($validator) {
         $input = $this->input();
         if (User::isNameExist($input['firstname'], $input['lastname'], $input['middleinitial'])) {
             $validator->errors()->add('firstname', "User named {$input['firstname']} {$input['lastname']} already exists.");
         }
         // add validation for contact_no
     });
     return $validator;
 }
开发者ID:ehomeuc,项目名称:ehome,代码行数:12,代码来源:RegisterUserRequest.php

示例7: getValidatorInstance

 /**
  * Validate for unique file hash
  * @return \Illuminate\Validation\Validator
  */
 public function getValidatorInstance()
 {
     $validator = parent::getValidatorInstance();
     $validator->after(function () use($validator) {
         if (!is_null($this->file('file')) && $this->file('file')->isValid()) {
             $file = $this->file('file');
             $csv_mime_types = ['text/csv', 'text/plain', 'application/csv', 'text/comma-separated-values', 'application/excel', 'application/vnd.ms-excel', 'application/vnd.msexcel', 'text/anytext', 'application/octet-stream', 'application/txt'];
             if (!in_array($file->getMimeType(), $csv_mime_types)) {
                 $validator->errors()->add('file', 'The file must be a CSV or Excel.');
             }
         }
     });
     return $validator;
 }
开发者ID:sadhakbj,项目名称:resourcecontracts.org,代码行数:18,代码来源:ImportRequest.php

示例8: getValidatorInstance

 /**
  * Modifikasi data input sebelum divalidasi, input juga akan diteruskan ke
  * LeadController untuk mengurangi modifikasi input sebelum menyimpan ke
  * database.
  *
  * @return Validator
  */
 public function getValidatorInstance()
 {
     $input = $this->all();
     // Menentukan jika kontraktor mengisi survey atau tidak
     // sama sekali
     if (!array_key_exists('s2_data', $input['lead']) && !array_key_exists('geo_data', $input['lead']) && !array_key_exists('chem_data', $input['lead']) && !array_key_exists('grav_data', $input['lead']) && !array_key_exists('elec_data', $input['lead']) && !array_key_exists('resi_data', $input['lead']) && !array_key_exists('oter_data', $input['lead'])) {
         $input['lead']['survey'] = null;
     } else {
         $input['lead']['survey'] = 1;
     }
     // Menggabungkan 3 field "Initiation date" menjadi satu field
     $input['lead']['initiate'] = Carbon::createFromDate($input['lead']['initiate']['year'], $input['lead']['initiate']['month'], $input['lead']['initiate']['day'])->toDateString();
     $input['lead']['latitude'] = $input['lead']['latitude_degree'] . "," . $input['lead']['latitude_minute'] . "," . $input['lead']['latitude_second'] . "," . $input['lead']['latitude_cardinal'];
     $input['lead']['longitude'] = $input['lead']['longitude_degree'] . "," . $input['lead']['longitude_minute'] . "," . $input['lead']['longitude_second'] . ",E";
     $this->getInputSource()->replace($input);
     return parent::getValidatorInstance();
 }
开发者ID:b813813,项目名称:harleen,代码行数:24,代码来源:LeadFormRequest.php

示例9: getValidatorInstance

 protected function getValidatorInstance()
 {
     $prefix = $this->model . '_';
     $all = $this->all();
     foreach ($all as $key => $value) {
         if (preg_match("/{$prefix}(?<name>.*)/", $key, $match)) {
             $name = $match['name'];
             $this[$name] = $value;
         }
     }
     if (!empty($this->alias)) {
         foreach ($this->alias as $key => $value) {
             $temp = $this[$key];
             if (empty($temp)) {
                 $this[$prefix . $key] = $this[$key] = ConvertHelper::alias($this[$value]);
             }
         }
     }
     return parent::getValidatorInstance();
 }
开发者ID:trongtri0705,项目名称:staff,代码行数:20,代码来源:ActiveRequest.php

示例10: getValidatorInstance

 /**
  * Validate for unique file hash
  * @return \Illuminate\Validation\Validator
  */
 public function getValidatorInstance()
 {
     $validator = parent::getValidatorInstance();
     $validator->after(function () use($validator) {
         if ($this->isMethod('POST')) {
             if ($this->file('file')->isValid()) {
                 $file = $this->file('file');
                 $hash = getFileHash($file->getPathName());
                 $contractService = app('App\\Nrgi\\Services\\Contract\\ContractService');
                 if ($contract = $contractService->getContractIfFileHashExist($hash)) {
                     $message = trans("The contract file is already present in our system. Please check the following Title of contract with which the uploaded file is linked and make necessary updates.");
                     $message .= sprintf("<div><a target='_blank' href='%s'>%s</a></div>", route('contract.show', $contract->id), $contract->title);
                     $validator->errors()->add('file', $message);
                 }
             } else {
                 $validator->errors()->add('file', $this->file('file')->getError());
             }
         }
     });
     return $validator;
 }
开发者ID:sadhakbj,项目名称:resourcecontracts.org,代码行数:25,代码来源:ContractRequest.php

示例11: getValidatorInstance

 protected function getValidatorInstance()
 {
     $dateHelper = new DateHelper();
     $data = $this->all();
     $data['name'] = $data['event-name'];
     $data['slug'] = str_slug($data['event-name']);
     $data['description'] = strip_tags($data['event-description'], '<br>');
     $data['description_plain'] = strip_tags($data['event-description'], '<br>');
     $data['street'] = $data['event-street'];
     $data['city'] = $data['event-city'];
     $data['state'] = $data['event-state'];
     $data['zip'] = $data['event-zip'];
     $data['date_start'] = $dateHelper->getStartTimeFromRange($data['daterangepicker']);
     if ($data['daterangepicker']) {
         $data['date_end'] = $dateHelper->getEndTimeFromRange($data['daterangepicker']);
     } else {
         $data['date_end'] = $data['daterangepicker'];
     }
     $this->getInputSource()->replace($data);
     /*modify data before send to validator*/
     return parent::getValidatorInstance();
 }
开发者ID:jonbrobinson,项目名称:aaulyp,代码行数:22,代码来源:EventRequest.php

示例12: getValidatorInstance

 /**
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function getValidatorInstance()
 {
     $validator = parent::getValidatorInstance();
     if (is_null($this->work)) {
         return $validator;
     }
     if ($this->work->crops->where('id', $this->input('crop_id'))->isEmpty()) {
         // 作業内容の選択が不正
         $validator->after(function ($validator) {
             $validator->errors()->add('work_id', trans('validation.required', ['attribute' => trans('validation.attributes.work_id')]));
         });
     }
     if ($this->work->use_pest_control) {
         if (empty(session()->get('workRecord.pesticides'))) {
             // 農薬が未選択
             $validator->after(function ($validator) {
                 $validator->errors()->add('pesticide', trans('validation.required', ['attribute' => trans('validation.attributes.pesticide')]));
             });
         }
     }
     return $validator;
 }
开发者ID:nana4rider,项目名称:mdiary,代码行数:25,代码来源:WorkRecordStoreRequest.php

示例13: getValidatorInstance

 /**
  * Get the validator instance for the request.
  *
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function getValidatorInstance()
 {
     $domain = false === ($pos = strpos($email = $this->input('email', ''), '@')) ? '' : substr($email, $pos + 1);
     $this->merge(['domain' => $domain]);
     return parent::getValidatorInstance();
 }
开发者ID:BePsvPT,项目名称:CCU,代码行数:11,代码来源:RegisterRequest.php


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