コード例 #1
0
ファイル: Address.php プロジェクト: kameshwariv/testexample
 /**
  * Validations based on market traits
  * @param array $options
  * @return bool
  */
 public function beforeValidate($options = [])
 {
     $validator = $this->validator();
     if (!empty($this->admin)) {
         $market_id = $this->getMarketFromCountry();
     } else {
         $market_id = $this->getMarketId();
     }
     $traitCountry = new TraitCountry();
     //use Market Traits to validate city.
     if (strtolower($traitCountry->getTrait($market_id, 'city_required')) == 'false') {
         $validator->remove('city');
     }
     if ($market_id == Market::MARKET_GERMANY || $market_id == Market::MARKET_UNITED_KINGDOM || $market_id == Market::MARKET_FRANCE || $market_id == Market::MARKET_SPAIN || $market_id == Market::MARKET_MEXICO) {
         $validator->remove('state_id');
     }
     //use Market Traits to validate Zip
     $zipQ = $traitCountry->getTrait($market_id, 'zip_qualifier');
     if (!empty($zipQ)) {
         $zipF = $traitCountry->getTrait($market_id, 'zip_format');
         $zipF = !empty($zipF) ? $zipF : null;
         $validator->remove('postal_code');
         $validator->add('postal_code', ['rule' => ['postal', $zipF, $zipQ], 'message' => 'Please use a valid Postal Code.']);
     }
     return TRUE;
 }
コード例 #2
0
ファイル: Phone.php プロジェクト: kameshwariv/testexample
 public function beforeValidate($options = array())
 {
     // market touch point
     $trait = new TraitCountry();
     $validator = $this->validator();
     $format = $trait->getTrait($this->getMarketId(), 'phone_format');
     //use Market Traits to validate city.
     if (!empty($format)) {
         $num = $trait->getTrait($this->getMarketId(), 'zip_qualifier');
         $validator->remove('phone');
         $validator->add('phone', ['rule' => ['phone', $format, $num], 'message' => 'Please supply a valid phone number.']);
     } else {
         $validator->remove('phone');
     }
     return TRUE;
 }
コード例 #3
0
ファイル: Presenter.php プロジェクト: kameshwariv/testexample
 /**
  * Get Fast start without looking up presenter
  * @param $agree_date
  * @param $market_id
  * @return bool|string
  */
 public function getFasterStartDeadline($agree_date, $market_id)
 {
     // market touch point
     $trait = new TraitCountry();
     $fast_start = $trait->getTrait($market_id, 'fast_start_date');
     if (!empty($fast_start)) {
         if ($agree_date < new DateTime($fast_start)) {
             $fast_start_end = $trait->getTrait($market_id, 'fast_start_end_date');
             $fast_start_end_date = new DateTime($fast_start_end);
         } else {
             $fast_start_end_date = date_add($agree_date, date_interval_create_from_date_string('92 days'));
         }
     } else {
         $fast_start_end_date = date_add($agree_date, date_interval_create_from_date_string('92 days'));
     }
     return date_format($fast_start_end_date, 'Y-m-d');
 }