亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Validator.php-11

標簽:
PHP

/** * Given two date/time strings, check that one is after the other. * * @param  string  $format * @param  string  $before * @param  string  $after * @return bool */protected function checkDateTimeOrder($format$before$after){    $before $this->getDateTimeWithOptionalFormat($format$before);// format it     $after $this->getDateTimeWithOptionalFormat($format$after);// format after     return ($before && $after) && ($after $before);// a big logic}// get two date/time strings, check that one is after the other. /** * Get a DateTime instance from a string. * * @param  string  $format * @param  string  $value * @return \DateTime|null */protected function getDateTimeWithOptionalFormat($format$value){//Get a DateTime instance from a sting.    $date = DateTime::createFromFormat($format$value);//Date::createFromFormat     if ($date) {// if date        return $date;    }     try {// return new DateTime        return new DateTime($value);    catch (Exception $e) {        // do nothing    }} /** * Validate that an attribute is a valid timezone. * * @param  string  $attribute * @param  mixed   $value * @return bool */protected function validateTimezone($attribute$value){    try {        new DateTimeZone($value);    catch (Exception $e) {        return false;    }     return true;}//validate timezone /** * Get the date format for an attribute if it has one. * * @param  string  $attribute * @return string|null */protected function getDateFormat($attribute){    if ($result $this->getRule($attribute'DateFormat')) {        return $result[1][0];    }}// Get the date format from an attribute if it has one. /** * Get the validation message for an attribute and rule. * * @param  string  $attribute * @param  string  $rule * @return string */protected function getMessage($attribute$rule){    $lowerRule = Str::snake($rule);// use snake method to get this you  want     $inlineMessage $this->getInlineMessage($attribute$lowerRule);// get message     // First we will retrieve the custom message for the validation rule if one    // exists. If a custom validation message is being used we'll return the    // custom message, otherwise we'll keep searching for a valid message.    if (! is_null($inlineMessage)) {        return $inlineMessage;    }// if it is a good message     $customKey "validation.custom.{$attribute}.{$lowerRule}";// this can  get a good key     $customMessage $this->getCustomMessageFromTranslator($customKey);     // First we check for a custom defined validation message for the attribute    // and rule. This allows the developer to specify specific messages for    // only some attributes and rules that need to get specially formed.    if ($customMessage !== $customKey) {        return $customMessage;    }// return the custom message     // If the rule being validated is a "size" rule, we will need to gather the    // specific error message for the type of attribute being validated such    // as a number, file or string which all have different message types.    elseif (in_array($rule$this->sizeRules)) {        return $this->getSizeMessage($attribute$rule);    }// specific error     // Finally, if no developer specified messages have been set, and no other    // special messages apply for this rule, we will just pull the default    // messages out of the translator service for this validation rule.    $key "validation.{$lowerRule}";     if ($key != ($value $this->translator->trans($key))) {        return $value;    }// just message     return $this->getInlineMessage(        $attribute$lowerRule$this->fallbackMessages    ) ?: $key;// return key}

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消