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


PHP Carbon::lte方法代码示例

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


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

示例1: computeStockOnHand

 /**
  * Compute stock on hand
  * @param unknown $currentRnum
  * @param unknown $previousRnum
  * @return multitype:|multitype:number Ambigous <string, number>
  */
 public function computeStockOnHand($currentRnum, $previousRnum = null)
 {
     $currentReplenish = ModelFactory::getInstance('TxnReplenishmentHeader')->with('salesman', 'details')->where('reference_number', $currentRnum)->first();
     $previousReplenish = '';
     if ($previousRnum) {
         $previousReplenish = ModelFactory::getInstance('StockOnHand')->with('items')->where('replenishment_number', $previousRnum)->first();
     }
     if (!$currentReplenish) {
         return false;
     }
     $stockOnHand = [];
     $to = new Carbon($currentReplenish->replenishment_date);
     $goLive = new Carbon(config('system.go_live_date'));
     //Replenishment
     if ($previousReplenish) {
         foreach ($previousReplenish->items as $item) {
             if (!isset($stockOnHand[$item->item_code])) {
                 $stockOnHand[$item->item_code] = 0;
             }
             $stockOnHand[$item->item_code] += $item->quantity;
         }
         $from = (new Carbon($previousReplenish->stock_date))->addDay();
     } else {
         foreach ($currentReplenish->details as $item) {
             if (!isset($stockOnHand[$item->item_code])) {
                 $stockOnHand[$item->item_code] = 0;
             }
             $stockOnHand[$item->item_code] += $item->quantity;
         }
         $from = new Carbon($to);
     }
     $salesmanCode = $currentReplenish->salesman->salesman_code;
     $dates = [];
     while ($from->lte($to)) {
         $date = $from->format('Y-m-d');
         $stockTransfers = ModelFactory::getInstance('TxnStockTransferInHeader')->with('details')->where(\DB::raw('DATE(transfer_date)'), $date)->where('salesman_code', $salesmanCode)->orderBy('transfer_date')->get();
         // Stock Transfer
         $stockTransferItemCount = [];
         if ($stockTransfers) {
             foreach ($stockTransfers as $stock) {
                 foreach ($stock->details as $item) {
                     if (!isset($stockOnHand[$item->item_code])) {
                         $stockOnHand[$item->item_code] = 0;
                     }
                     $stockOnHand[$item->item_code] += $item->quantity;
                 }
             }
         }
         $sales = ModelFactory::getInstance('TxnSalesOrderHeader')->with('details', 'customer')->where(\DB::raw('DATE(so_date)'), $date)->where('salesman_code', $salesmanCode)->orderBy('so_date')->get();
         // Sales Invoice
         $salesItemCount = [];
         if ($sales) {
             foreach ($sales as $sale) {
                 foreach ($sale->details as $item) {
                     if (!isset($stockOnHand[$item->item_code])) {
                         $stockOnHand[$item->item_code] = 0;
                     }
                     if (false !== strpos($sale->customer->customer_name, '_Van to Warehouse')) {
                         $stockOnHand[$item->item_code] -= $item->order_qty;
                     } elseif (false !== strpos($sale->customer->customer_name, '_Adjustment')) {
                         $stockOnHand[$item->item_code] -= $item->order_qty;
                     } else {
                         $stockOnHand[$item->item_code] -= $item->quantity;
                     }
                 }
             }
         }
         $returns = ModelFactory::getInstance('TxnReturnHeader')->with('details', 'customer')->where(\DB::raw('DATE(return_date)'), $date)->where('salesman_code', $salesmanCode)->orderBy('return_date')->get();
         // Returns Invoice
         $returnsItemCount = [];
         if ($returns) {
             foreach ($returns as $return) {
                 foreach ($return->details as $item) {
                     if (!isset($stockOnHand[$item->item_code])) {
                         $stockOnHand[$item->item_code] = 0;
                     }
                     $stockOnHand[$item->item_code] += $item->quantity;
                 }
             }
         }
         if ($from->eq($to)) {
             foreach ($currentReplenish->details as $item) {
                 if (!isset($stockOnHand[$item->item_code])) {
                     $stockOnHand[$item->item_code] = 0;
                 }
                 $stockOnHand[$item->item_code] -= $item->quantity;
             }
         }
         $stock = ModelFactory::getInstance('StockOnHand');
         if ($from->eq($to)) {
             $stock->replenishment_number = $currentReplenish->reference_number;
         } else {
             $stock->replenishment_number = $previousReplenish ? $previousReplenish->replenishment_number : $currentReplenish->reference_number;
         }
//.........这里部分代码省略.........
开发者ID:atudz,项目名称:SFAReport,代码行数:101,代码来源:ReportsPresenter.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: isValid

 /**
  * @inheritdoc
  */
 public function isValid($value)
 {
     $this->setValue($value);
     $datePassed = new Carbon($value);
     if ($datePassed->lte($this->minDate)) {
         $this->error(self::INVALID);
         return false;
     }
     return true;
 }
开发者ID:atasciuc,项目名称:zend-expressive-validation,代码行数:13,代码来源:IsDateGreater.php

示例4: push

 /**
  * Schedule a job to run after a specific time in the future.
  *
  * @param Job $job
  * @param Carbon $runAt
  *
  * @return Job
  */
 public function push(Job $job, Carbon $runAt)
 {
     if ($runAt->lte(Carbon::now())) {
         throw new InvalidArgumentException('The provided execution time is in the past');
     }
     $job->schedulable = true;
     $job->run_at = $runAt;
     $job->state = JobState::SCHEDULED;
     $job->save();
     return $job;
 }
开发者ID:MarkVaughn,项目名称:illuminated,代码行数:19,代码来源:JobScheduler.php

示例5: 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

示例6: available

 public function available()
 {
     date_default_timezone_set("America/Chicago");
     $dbstart = DB::table('config')->where('name', '=', 'competition_start')->first();
     $dbend = DB::table('config')->where('name', '=', 'competition_end')->first();
     $startclear = 0;
     $endclear = 0;
     // If both are null
     if ($dbstart->val_datetime == '0000-00-00 00:00:00') {
         $startclear = 1;
     }
     if ($dbend->val_datetime == '0000-00-00 00:00:00') {
         $endclear = 1;
     }
     if ($startclear == 1 & $endclear == 1) {
         return 1;
     }
     // If both are valid dates, see if we're valid
     if ($startclear == 0 && $endclear == 0) {
         $cstart = new Carbon($dbstart->val_datetime);
         $cend = new Carbon($dbend->val_datetime);
         $now = new Carbon();
         if ($now->between($cstart, $cend)) {
             return 1;
         } else {
             // Now we check if it's before or after the competition
             $msg = "";
             if ($cend->lte(Carbon::now())) {
                 $msg = "The competition ended at " . $dbend->val_datetime;
             } else {
                 $msg = "The competition does not start until " . $dbstart->val_datetime;
             }
             return $msg;
         }
     }
     if ($endclear == 0) {
         $cend = new Carbon($dbend->val_datetime);
         if ($cend->gte(Carbon::now())) {
             return 1;
         }
         return "The competition is over.";
     }
     if ($startclear == 0) {
         $cstart = new Carbon($dbstart->val_datetime);
         if ($cstart->lte(Carbon::now())) {
             return 1;
         }
         return "The competition does not start until " . $cstart;
     }
 }
开发者ID:DakotaStateUniversity,项目名称:RE-CTF,代码行数:50,代码来源:CompetitionController.php

示例7: delayExceeded

 /**
  * @param unknown $permit_delay
  * @param unknown $session_id
  * @return number|boolean
  */
 public function delayExceeded($permit_delay, $session_id)
 {
     Storage::put('inDelayExceeded_permit_delay', json_encode($permit_delay));
     Storage::put('inDelayExceeded_session_id', $session_id);
     if ($permit_delay == 0) {
         return 0;
     } else {
         $objThreeStepApprovedTime = $this->where('session_id', $session_id)->first();
         Storage::put('three_step_approved_time.txt', json_encode($objThreeStepApprovedTime));
         if ($objThreeStepApprovedTime == null) {
             Storage::put('in_delay_exceeded_ts_user_null', 'yes');
             return 1;
         }
         $permitted_time = Carbon::now()->subMinutes($permit_delay);
         Storage::put('inDelayExceeded_permitted_time', json_encode($permitted_time));
         Storage::put('inDelayExceeded_last_update', $objThreeStepApprovedTime->last_update_time);
         Storage::put('inDelayExceeded_permitted_time_date_property', $permitted_time->date);
         $objCarbonLastUpdate = new Carbon($objThreeStepApprovedTime->last_update_time);
         $objCarbonPermittedTime = new Carbon($permitted_time->date);
         Storage::put('in_delay_exceeded_result', $objCarbonLastUpdate->lte($objCarbonPermittedTime));
         return $objCarbonLastUpdate->lte($objCarbonPermittedTime);
     }
 }
开发者ID:jenniferbradley49,项目名称:testing_app_two,代码行数:28,代码来源:ThreeStepApprovedTime.php

示例8: days

 public function days()
 {
     // Use carbon!
     $start_date = new Carbon($this->start_date);
     $end_date = new Carbon($this->end_date);
     // Array for output
     $days = [];
     // This only works when the start date is before the end date
     if ($start_date->lte($end_date)) {
         // $date keeps track of the current date as we loop towards the end
         $date = $start_date;
         while ($date->lte($end_date)) {
             $days[] = (object) ['name' => $date->formatLocalized('%A'), 'date' => clone $date];
             $date->addDay();
         }
     }
     return $days;
 }
开发者ID:playatech,项目名称:laravel-voldb,代码行数:18,代码来源:Event.php

示例9: generate

 public static function generate($shift)
 {
     // Delete all existing slots for this shift
     Slot::where('shift_id', $shift->id)->delete();
     // Loop over shift days
     $date = new Carbon($shift->start_date);
     $end_date = new Carbon($shift->end_date);
     while ($date->lte($end_date)) {
         // Convert shift times to seconds
         $start = Slot::timeToSeconds($shift->start_time);
         $end = Slot::timeToSeconds($shift->end_time);
         $duration = Slot::timeToSeconds($shift->duration);
         // Now loop over the times based on the slot duration
         for ($time = $start; $time + $duration <= $end; $time += $duration) {
             $slot = ['shift_id' => $shift->id, 'start_date' => $date->format('Y-m-d'), 'start_time' => Slot::secondsToTime($time), 'end_time' => Slot::secondsToTime($time + $duration)];
             Slot::create($slot);
         }
         $date->addDay();
     }
 }
开发者ID:playatech,项目名称:laravel-voldb,代码行数:20,代码来源:Slot.php

示例10: validateNotAfterField

 public function validateNotAfterField($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->lte($value2);
 }
开发者ID:npmweb,项目名称:laravel-validator-custom-rules,代码行数:19,代码来源:CustomValidator.php

示例11: isPaymentPastDue

 /**
  * Check if the payment is past due
  * @return bool
  */
 private function isPaymentPastDue()
 {
     $invoices = $this->getInvoices();
     $now = Carbon::now(Config::get("app.timezone"));
     foreach ($invoices as $invoice) {
         if ($invoice->remaining_due <= 0) {
             continue;
         }
         $invoiceDueDate = new Carbon($invoice->due_date);
         if ($invoiceDueDate->lte($now)) {
             return true;
         }
     }
     return false;
 }
开发者ID:sonarsoftware,项目名称:customer_portal,代码行数:19,代码来源:BillingController.php

示例12: hasAged

 /**
  * Returns true when a content is older than a year
  *
  * @return bool
  */
 public function hasAged()
 {
     $date = new Carbon($this->getAttribute($this->dateKey));
     return $date->lte(new Carbon('last year'));
 }
开发者ID:salvo1404,项目名称:driesvints.com,代码行数:10,代码来源:AbstractContent.php

示例13: isOpenStarted

 /**
  * Determines if a date range has a lower bound.
  *
  * @return bool
  */
 public function isOpenStarted()
 {
     return is_null($this->after) || !is_null($this->before) && $this->before->lte($this->after);
 }
开发者ID:20TRIES,项目名称:date_range,代码行数:9,代码来源:DateRange.php


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