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


PHP Carbon::gte方法代码示例

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


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

示例1: isExpired

 public function isExpired()
 {
     $now = new Carbon();
     if ($now->gte(new Carbon($this->expire_token))) {
         return true;
     }
     return false;
 }
开发者ID:nothing628,项目名称:git-control,代码行数:8,代码来源:Oauth.php

示例2: active

 /**
  * Check if the Feature is active
  *
  * @return bool
  */
 public function active()
 {
     $now = new Carbon();
     if ($this->start_time && $this->end_time) {
         return $now->gte($this->start_time) && $now->lte($this->end_time);
     } else {
         if ($this->start_time) {
             return $now->gte($this->start_time);
         } else {
             if ($this->end_time) {
                 return $now->lte($this->end_time);
             } else {
                 return true;
             }
         }
     }
 }
开发者ID:heldtogether,项目名称:venice-php,代码行数:22,代码来源:TimedFeature.php

示例3: isOpenVoting

 /**
  * Checks whether a battle is open for voting
  */
 public function isOpenVoting()
 {
     $trendingperiod = config('rap-battle.trendingperiod', 168);
     // battles after this date will be considered for trending
     $timeoldest = new Carbon();
     $timeoldest->subHours($trendingperiod);
     // creation date
     $cre = new Carbon($this->created_at);
     return $cre->gte($timeoldest);
 }
开发者ID:Rap-Battle-App,项目名称:Backend,代码行数:13,代码来源:Battle.php

示例4: matchesPeriod

 /**
  * Check if rule matches a period
  *
  * @param RedirectRule $rule
  * @return bool
  */
 private function matchesPeriod(RedirectRule $rule)
 {
     if ($rule->getFromDate() instanceof Carbon && $rule->getToDate() instanceof Carbon) {
         return $this->matchDate->between($rule->getFromDate(), $rule->getToDate());
     }
     if ($rule->getFromDate() instanceof Carbon && $rule->getToDate() === null) {
         return $this->matchDate->gte($rule->getFromDate());
     }
     if ($rule->getFromDate() === null && $rule->getToDate() instanceof Carbon) {
         return $this->matchDate->lte($rule->getToDate());
     }
     return true;
 }
开发者ID:adrenth,项目名称:redirect,代码行数:19,代码来源:RedirectManager.php

示例5: filter

 /**
  * Datetime exact match check as well as between check
  * @param string $content
  * @param string $search
  * @param string $type
  * @return bool
  */
 public function filter($content, $search, $type)
 {
     $search = is_array($search) ? $search : [$search];
     $search = array_map(function ($searchValue) {
         return is_a($searchValue, Carbon::class) ? $searchValue : new Carbon($searchValue);
     }, $search);
     $current = new Carbon($content);
     switch ($type) {
         case 'in':
             return $current->gte($search[0]) && $current->lt($search[1]);
             break;
         default:
             return $current->eq($search[0]);
     }
 }
开发者ID:web-feet,项目名称:coasterframework,代码行数:22,代码来源:Datetime.php

示例6: update_time

 public function update_time(Request $request)
 {
     if (!Auth::Check()) {
         return -2;
     }
     if (!Auth::user()->getAdmin()) {
         return -1;
     }
     if (empty($request->input('competition_start')) || empty($request->input('competition_end'))) {
         return 0;
     }
     $newstart = new Carbon($request->input('competition_start'));
     $newend = new Carbon($request->input('competition_end'));
     if ($newstart->gte($newend)) {
         DB::table('config')->where('name', '=', 'competition_start')->update(['val_datetime' => $newstart]);
         DB::table('config')->where('name', '=', 'competition_end')->update(['val_datetime' => '0000-00-00 00:00:00']);
     } else {
         // Verbose else
         DB::table('config')->where('name', '=', 'competition_start')->update(['val_datetime' => $newstart]);
         DB::table('config')->where('name', '=', 'competition_end')->update(['val_datetime' => $newend]);
     }
     return 1;
 }
开发者ID:DakotaStateUniversity,项目名称:RE-CTF,代码行数:23,代码来源:CompetitionController.php

示例7: validateNotBeforeField

 public function validateNotBeforeField($attribute, $value, $parameters)
 {
     $this->requireParameterCount(1, $parameters, 'before_field');
     $value2 = array_get($this->data, $parameters[0]);
     // make them Carbon dates
     if (!$value instanceof Carbon) {
         if (strtotime($value) === false) {
             return false;
         }
         $value = new Carbon($value);
     }
     if (!$value2 instanceof Carbon) {
         if (strtotime($value2) === false) {
             return false;
         }
         $value2 = new Carbon($value2);
     }
     return $value->gte($value2);
 }
开发者ID:npmweb,项目名称:laravel-validator-custom-rules,代码行数:19,代码来源:CustomValidator.php

示例8: scanFile

 protected function scanFile(FileRecord $file)
 {
     $virusTotal = new VirusTotalFile(config('virustotal.api_key'));
     if ($file->shouldCheckScan()) {
         $this->info(sprintf('Checking scan for file: %s (#%d)', $file->client_name, $file->id));
         $this->throttler->throttle(1);
         $result = $virusTotal->getReport($file->hash);
         $file->scan_checked_at = Carbon::now();
         $file->save();
         if ($result['response_code'] === 1) {
             $scannedAt = new Carbon($result['scan_date']);
             $cutoff = new Carbon('-2 weeks');
             // Check if this scan record already exists in DB
             $exists = Scan::where('virustotal_scan_id', '=', $result['scan_id'])->count() > 0;
             if ($scannedAt->gte($cutoff) && !$exists) {
                 /** @var Scan $scan */
                 $scan = Scan::create(['file_record_id' => $file->id, 'virustotal_scan_id' => $result['scan_id'], 'total' => $result['total'], 'positives' => $result['positives'], 'scanned_at' => $scannedAt, 'scans' => $result['scans']]);
                 $this->info(sprintf('Scan result: %d/%d', $scan->positives, $scan->total));
                 // We now have a report from a requested scan
                 $file->scan_requested_at = null;
                 $file->save();
                 $deleted = $this->actionScanResult($file, $scan);
                 if ($deleted) {
                     // Nothing else to do if deleted
                     return;
                 }
             }
         }
     }
     if ($file->shouldScanFile()) {
         // Max filesize for public API is 32mb
         if ($file->filesize <= 32 * pow(1024, 2)) {
             $this->info(sprintf('Uploading file for scan: %s (#%d)', $file->client_name, $file->id));
             $this->throttler->throttle(1);
             $result = $virusTotal->scan($file->filePath());
             if ($result['response_code'] === 1) {
                 $file->scan_requested_at = Carbon::now();
                 $file->save();
             }
         } else {
             // TODO: private API
         }
     } elseif ($file->shouldRescanFile()) {
         $this->info(sprintf('Requesting re-scan for file: %s (#%d)', $file->client_name, $file->id));
         $this->throttler->throttle(1);
         $result = $virusTotal->rescan($file->hash);
         if ($result['response_code'] === 1) {
             $file->scan_requested_at = Carbon::now();
             $file->save();
         }
     }
 }
开发者ID:kimoi,项目名称:madokami.com,代码行数:52,代码来源:ScanFiles.php


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