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


PHP Carbon::gt方法代码示例

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


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

示例1: scopeTourScheduleBetween

 function scopeTourScheduleBetween($q, \Carbon\Carbon $date1 = null, \Carbon\Carbon $date2 = null)
 {
     ////////////////////////////////////////////////////
     // Compare date1 & date2 for which one is earlier //
     ////////////////////////////////////////////////////
     if ($date1 && $date2) {
         if ($date1->gt($date2)) {
             $tmp = $date2;
             $date2 = $date1;
             $date1 = $tmp;
         }
     }
     ///////////////
     // Run Query //
     ///////////////
     if ($date1 && $date2) {
         $q->where(function ($q) use($date1, $date2, $budget_query) {
             $q->where(function ($q) use($date1, $date2, $budget_query) {
                 // No departure until
                 $query['schedules']['$elemMatch']['departure_until'] = '';
                 $query['schedules']['$elemMatch']['departure'] = ['$gte' => $date1->format('Y-m-d'), '$lte' => $date2->format('Y-m-d')];
                 $q->whereRaw($query);
             })->orWhere(function ($q) use($date1, $date2, $budget_query) {
                 // with departure until
                 $query['schedules']['$elemMatch']['departure_until'] = ['$gte' => $date1->format('Y-m-d')];
                 $query['schedules']['$elemMatch']['departure'] = ['$lte' => $date2->format('Y-m-d')];
                 $q->whereRaw($query);
             });
         });
     } elseif ($date1) {
         $q->where(function ($q) use($date1, $budget_query) {
             $q->where(function ($q) use($date1, $budget_query) {
                 // No departure until
                 $query['schedules']['$elemMatch']['departure_until'] = '';
                 $query['schedules']['$elemMatch']['departure'] = ['$gte' => $date1->format('Y-m-d')];
                 $q->whereRaw($query);
             })->orWhere(function ($q) use($date1, $budget_query) {
                 // with departure until
                 $query['schedules']['$elemMatch']['departure_until'] = ['$gte' => $date1->format('Y-m-d')];
                 $q->whereRaw($query);
             });
         });
     } elseif ($date2) {
         $q->where(function ($q) use($date1, $budget_query) {
             $q->where(function ($q) use($date1, $budget_query) {
                 // No departure until
                 $query['schedules']['$elemMatch']['departure_until'] = '';
                 $query['schedules']['$elemMatch']['departure'] = ['$lte' => $date2->format('Y-m-d')];
                 $q->whereRaw($query);
             })->orWhere(function ($q) use($date1, $budget_query) {
                 // with departure until
                 $query['schedules']['$elemMatch']['departure_until'] = ['$lte' => $date2->format('Y-m-d')];
                 $q->whereRaw($query);
             });
         });
     }
 }
开发者ID:erickmo,项目名称:CapcusAPI,代码行数:57,代码来源:EmbedTourSchedules.php

示例2: interval

 public function interval($start, $end, $interval)
 {
     $result = array();
     $date = new Carbon($start);
     $endDate = new Carbon($end);
     while ($endDate->gt($date)) {
         $date->modify($interval);
         $result[] = $date->copy();
     }
     return $result;
 }
开发者ID:mauris,项目名称:samsui,代码行数:11,代码来源:Date.php

示例3: funkySinceDate

 public function funkySinceDate()
 {
     $date = new Carbon($this->customer_since);
     if ($date->gt(Carbon::create(2009))) {
         return $date->year;
     } elseif ($date->between(Carbon::create(2000), Carbon::create(2009))) {
         return 'Oh-' . $date->year % 10;
     } elseif ($date->between(Carbon::create(1990), Carbon::create(1999))) {
         return 'ninety-' . $date->year % 10;
     } elseif ($date->between(Carbon::create(1980), Carbon::create(1989))) {
         return 'eighty-' . $date->year % 10;
     } elseif ($date->between(Carbon::create(1970), Carbon::create(1979))) {
         return 'UNIX-' . $date->year % 10;
     } else {
         return 'forever';
     }
 }
开发者ID:GobleB,项目名称:POS-CRUD,代码行数:17,代码来源:Customer.php

示例4: validateAfterField

 public function validateAfterField($attribute, $value, $parameters)
 {
     $this->requireParameterCount(1, $parameters, 'after_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->gt($value2);
 }
开发者ID:npmweb,项目名称:laravel-validator-custom-rules,代码行数:19,代码来源:CustomValidator.php

示例5: checkPurchasability

 public function checkPurchasability(Carbon $now = null)
 {
     $this->checkForQuantity();
     if (!is_null($this->purchasable) && !$this->purchasable) {
         throw new NotForSaleException($this->getDesignation(), 2);
     }
     if (!is_null($this->min_purch_quantity) && $this->quantity < $this->min_purch_quantity) {
         throw new PurchaseQuantityException($this->getDesignation(), $this->min_purch_quantity, 1);
     }
     if (!is_null($this->max_purch_quantity) && $this->quantity > $this->max_purch_quantity) {
         throw new PurchaseQuantityException($this->getDesignation(), $this->max_purch_quantity, 2);
     }
     if (is_null($now)) {
         $now = new Carbon('now');
     }
     if (!is_null($this->start_time) & !is_null($this->end_time)) {
         if (!$now->between($this->start_time, $this->end_time)) {
             throw new OutsideSaleTimeException($this->getDesignation(), $this->start_time, $this->end_time, 1);
         }
     } else {
         if (!is_null($this->start_time) & is_null($this->end_time)) {
             if ($now->lt($this->start_time)) {
                 throw new OutsideSaleTimeException($this->getDesignation(), $this->start_time, null, 2);
             }
         } else {
             if (is_null($this->start_time) & !is_null($this->end_time)) {
                 if ($now->gt($this->end_time)) {
                     throw new OutsideSaleTimeException($this->getDesignation(), $now, $this->end_time, 3);
                 }
             }
         }
     }
     if ($this->isSoldOut()) {
         throw new NotForSaleException($this->getDesignation(), 1);
     }
     return true;
 }
开发者ID:edcarr0016,项目名称:display_repo,代码行数:37,代码来源:VendibleTrait.php

示例6: toDt

 /**
  * Return a DateTime from a date string and a time string
  *
  * @param $date
  * @param $time
  * @return Carbon
  */
 public static function toDt($date, $time)
 {
     switch ($date) {
         case "Aujourd'hui":
             $dt = Carbon::today();
             break;
         case "Hier":
             $dt = Carbon::yesterday();
             break;
         default:
             list($day, $month) = preg_split('/\\s/', $date);
             $dt = new Carbon();
             $dt->day($day);
             $dt->month(self::getMonthNumber($month));
     }
     // Set up the time
     list($hour, $minute) = preg_split('/:/', $time);
     $dt->hour = $hour;
     $dt->minute = $minute;
     if ($dt->gt(Carbon::tomorrow()->subSecond())) {
         $dt->year--;
     }
     return $dt->format('Y-m-d H:m');
 }
开发者ID:inscriptionweb,项目名称:leboncoin-crawler,代码行数:31,代码来源:SearchResultDateTimeParser.php

示例7: between

 /**
  * Determines if the instance is between two others
  *
  * @param  Carbon  $dt1
  * @param  Carbon  $dt2
  * @param  boolean $equal  Indicates if a > and < comparison should be used or <= or >=
  *
  * @return boolean
  */
 public function between(Carbon $dt1, Carbon $dt2, $equal = true)
 {
     if ($dt1->gt($dt2)) {
         $temp = $dt1;
         $dt1 = $dt2;
         $dt2 = $temp;
     }
     if ($equal) {
         return $this->gte($dt1) && $this->lte($dt2);
     } else {
         return $this->gt($dt1) && $this->lt($dt2);
     }
 }
开发者ID:hepl-archives,项目名称:mini-blog,代码行数:22,代码来源:Carbon.php

示例8: contains

 public function contains(Carbon $date_time)
 {
     return $date_time->gt($this->after) && $date_time->lt($this->before);
 }
开发者ID:20TRIES,项目名称:date_range,代码行数:4,代码来源:DateRange.php

示例9: buildPayload

 /**
  * @param $data
  * @return array
  */
 private function buildPayload($data)
 {
     $payload = ['id' => (int) $data[0], 'name' => trim($data[1]), 'account_type_id' => (int) $data[2], 'account_status_id' => (int) $data[3], 'contact_name' => trim($data[16])];
     $unformattedAddress = ['line1' => trim($data[7]), 'line2' => trim($data[8]), 'city' => trim($data[9]), 'state' => trim($data[10]), 'county' => trim($data[11]), 'zip' => trim($data[12]), 'country' => trim($data[13]), 'latitude' => trim($data[14]), 'longitude' => trim($data[15])];
     $formattedAddress = $this->addressFormatter->formatAddress($unformattedAddress, false);
     $payload = array_merge($payload, $formattedAddress);
     /**
      * We don't do a ton of validation here, as the API call will fail if this data is invalid anyway.
      */
     if (trim($data[4])) {
         $payload['account_groups'] = explode(",", trim($data[4]));
     }
     if (trim($data[5])) {
         $payload['sub_accounts'] = explode(",", trim($data[5]));
     }
     if (trim($data[6])) {
         $carbon = new Carbon($data[6]);
         $now = Carbon::now();
         if ($carbon->gt($now)) {
             $payload['next_bill_date'] = trim($carbon->toDateString());
         }
     }
     if (trim($data[17])) {
         $payload['role'] = trim($data[17]);
     }
     if (trim($data[18])) {
         $payload['email_address'] = trim($data[18]);
     }
     if (trim($data[19])) {
         $payload['email_message_categories'] = explode(",", trim($data[19]));
     } else {
         $payload['email_message_categories'] = [];
     }
     $phoneNumbers = [];
     if (trim($data[20])) {
         $phoneNumbers['work'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[20])), 'extension' => trim($data[21])];
     }
     if (trim($data[22])) {
         $phoneNumbers['home'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[22])), 'extension' => null];
     }
     if (trim($data[23])) {
         $phoneNumbers['mobile'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[23])), 'extension' => null];
     }
     if (trim($data[24])) {
         $phoneNumbers['fax'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[24])), 'extension' => null];
     }
     if (count($phoneNumbers) > 0) {
         $payload['phone_numbers'] = $phoneNumbers;
     }
     return $payload;
 }
开发者ID:sonarsoftware,项目名称:importer,代码行数:55,代码来源:AccountImporter.php

示例10: hasExpired

 /**
  * {@inheritdoc}
  */
 public function hasExpired()
 {
     $now = new Carbon();
     return $now->gt($this->expiresAt());
 }
开发者ID:aedart,项目名称:scaffold,代码行数:8,代码来源:ScaffoldIndex.php


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