本文整理汇总了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;
}
示例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;
}
示例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]);
}
}
}
示例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;
}
示例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;
}