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


PHP Carbon::addYear方法代码示例

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


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

示例1: getAvailableStartYears

 public static function getAvailableStartYears()
 {
     $years = [];
     $date = new Carbon('1 year ago');
     $years[] = (int) $date->format('Y');
     $years[] = (int) $date->addYear()->format('Y');
     $years[] = (int) $date->addYear()->format('Y');
     return $years;
 }
开发者ID:jamesprices,项目名称:iep-printing-php,代码行数:9,代码来源:Iep.php

示例2: addInterval

 public function addInterval(Carbon $date)
 {
     switch ($this->interval) {
         case 'yearly':
             $date->addYear();
             break;
         case 'quarterly':
             $date->addMonths(3);
             break;
         case 'weekly':
             $date->addWeek();
             break;
         case 'monthly':
         default:
             $date->addMonth();
     }
     return $date;
 }
开发者ID:SAIBA0011,项目名称:laravel-billing,代码行数:18,代码来源:Plan.php

示例3: testRegister

 public function testRegister()
 {
     $birthday = new Carbon();
     $birthday->addYear(-23);
     $this->visit('/auth/register')->type('user1', 'name')->type('user1@case.edu', 'email')->type('useruser', 'password')->type('useruser', 'password_confirmation')->type($birthday->toDateTimeString(), 'bdate')->select('1', 'gender')->type('2000', 'daily_calories');
     $map = [];
     $restrictions = Restriction::all();
     foreach ($restrictions as $restriction) {
         $val = round(mt_rand() / mt_getrandmax());
         $map[$restriction->id] = $val;
         $this->type($val + 1, 'restriction' . ($restriction->id + 1));
     }
     $this->press('Register')->seePageIs('/home');
     $this->seeInDatabase('users', ['name' => 'user1', 'email' => 'user1@case.edu', 'bdate' => $birthday->toDateString(), 'gender' => '0', 'daily_calories' => '2000']);
     $user = \App\User::whereEmail('user1@case.edu')->first();
     foreach ($restrictions as $restriction) {
         if ($map[$restriction->id] == 1) {
             $this->seeInDatabase('restriction_user', ['user_id' => $user->id, 'restriction_id' => $restriction->id]);
         }
     }
 }
开发者ID:lucyktan,项目名称:EECS-393-Nutrition-App,代码行数:21,代码来源:UserAuthTest.php

示例4: multiYearInOut

 /**
  * @param array  $earned
  * @param array  $spent
  * @param Carbon $start
  * @param Carbon $end
  *
  * @return array
  */
 protected function multiYearInOut(array $earned, array $spent, Carbon $start, Carbon $end)
 {
     $entries = new Collection();
     while ($start < $end) {
         $incomeSum = $this->pluckFromArray($start->year, $earned);
         $expenseSum = $this->pluckFromArray($start->year, $spent) * -1;
         $entries->push([clone $start, $incomeSum, $expenseSum]);
         $start->addYear();
     }
     $data = $this->generator->multiYearInOut($entries);
     return $data;
 }
开发者ID:zjean,项目名称:firefly-iii,代码行数:20,代码来源:ReportController.php

示例5: multiYearInOutSummarized

 /**
  * @param array  $earned
  * @param array  $spent
  * @param Carbon $start
  * @param Carbon $end
  *
  * @return array
  */
 protected function multiYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end)
 {
     $income = '0';
     $expense = '0';
     $count = 0;
     while ($start < $end) {
         $currentIncome = $this->pluckFromArray($start->year, $earned);
         $currentExpense = $this->pluckFromArray($start->year, $spent);
         $income = bcadd($income, $currentIncome);
         $expense = bcadd($expense, $currentExpense);
         $count++;
         $start->addYear();
     }
     $data = $this->generator->multiYearInOutSummarized($income, $expense, $count);
     return $data;
 }
开发者ID:roberthorlings,项目名称:firefly-iii,代码行数:24,代码来源:ReportController.php


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