本文整理汇总了PHP中Carbon\Carbon::addDay方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::addDay方法的具体用法?PHP Carbon::addDay怎么用?PHP Carbon::addDay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::addDay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
//.........这里部分代码省略.........
示例2: queuePostMatchEmail
private function queuePostMatchEmail(\PlayFooty\Event $event)
{
Log::info(__METHOD__);
$postMatchDate = new Carbon($event->event_date . " " . $event->start_time);
$postMatchDate->addDay(1)->setTime(10, 00);
Queue::later($postMatchDate, new SendPostMatchEmail($event));
}
示例3: budgetProgress
public function budgetProgress()
{
$this->_debug = Input::get('debug') == 'true' ? true : false;
$budget = Input::get('budget');
if (is_null($budget)) {
return App::abort(404);
}
$key = cacheKey('budgetProgress', $budget, Session::get('period'));
if (Cache::has($key)) {
return Response::json(Cache::get($key));
} else {
// so the current month, right?
$month = Session::get('period');
$end = intval($month->format('t'));
$clone = new Carbon($month->format('Y-m-d'));
$clone->modify('first day of this month');
$data = array('cols' => array(array('id' => 'day', 'label' => 'Day of the month', 'type' => 'string', 'p' => array('role' => 'domain')), array('id' => 'left', 'label' => $clone->format('F Y'), 'type' => 'number', 'p' => array('role' => 'data')), array('id' => 'Spentavg', 'label' => 'Avg', 'type' => 'number', 'p' => array('role' => 'data'))));
// get the latest budgets with this name:
$budgets = Auth::user()->budgets()->orderBy('date', 'DESC')->get();
$current = null;
$others = array();
foreach ($budgets as $b) {
$bName = Crypt::decrypt($b->name);
$bDate = new Carbon($b->date);
if ($bDate == $clone && $bName == $budget && is_null($current)) {
$current = $b;
} else {
if ($bName == $budget && (isset($current) && $current->id != $b->id || is_null($current))) {
$others[] = $b->id;
}
}
}
$index = 0;
$spent = 0;
$previouslySpent = 0;
for ($i = 1; $i <= $end; $i++) {
// get expenses for budget on this day.
$data['rows'][$index]['c'][0]['v'] = $clone->format('j F');
if (!is_null($current)) {
$expenses = floatval($current->transactions()->where('onetime', '=', 0)->where('date', '=', $clone->format('Y-m-d'))->sum('amount')) * -1;
$spent += $expenses;
$data['rows'][$index]['c'][1]['v'] = $spent;
}
if (count($others) > 0) {
// now for all previous budgets.
$oldExpenses = floatval(Auth::user()->transactions()->where('onetime', '=', 0)->whereIn('budget_id', $others)->where(DB::Raw('DATE_FORMAT(`date`,"%e")'), '=', $i)->sum('amount')) * -1 / count($others);
$previouslySpent += $oldExpenses;
$data['rows'][$index]['c'][2]['v'] = $previouslySpent;
}
$clone->addDay();
$index++;
}
if ($this->_debug) {
return '<pre>' . print_r($data, true) . '</pre>';
}
Cache::put($key, $data, 5000);
return Response::json($data);
}
}
示例4: fromDateToYuleDate
/**
* Returns the yule party date for the given year
*
* @param Carbon $date
* @return Carbon
*/
private function fromDateToYuleDate(Carbon $date)
{
while ($date->dayOfWeek != Carbon::FRIDAY) {
$date->addDay();
}
$date->addDays(8);
return $date;
}
示例5: isValid
public static function isValid($token)
{
$validity = new Carbon();
$validity->addDay(2);
if (RequestRegister::where('token', '=', $token)->where('created_at', '<', $validity)->where('isUsed', '!=', 1)->get()->count() > 0) {
RequestRegister::where('token', '=', $token)->where('created_at', '<', $validity)->first()->setUsed();
return true;
}
return false;
}
示例6: index
/**
* Display a listing of tarefas
*
* @return Response
*/
public function index()
{
$data = Input::get();
$data['view'] = Input::has('view') ? Input::get('view') : 'today';
// today, late, next, done
$data['paginate'] = Input::has('paginate') ? Input::get('paginate') : 10;
$dt = new Carbon();
$tarefas = Tarefa::where(function ($query) use($data, $dt) {
switch ($data['view']) {
case 'late':
$query->where('date', '<', $dt->format('Y-m-d'))->where('done', false);
break;
case 'next':
$query->where('date', '>', $dt->format('Y-m-d'))->where('done', false);
break;
case 'done':
$query->where('done', true);
break;
default:
// TODAY
$query->where('date', '>=', $dt->startOfDay()->format('Y-m-d'))->where('date', '<=', $dt->endOfDay()->format('Y-m-d'));
break;
}
})->orderBy(Input::get('order_by', 'date'), Input::get('order', 'DESC'))->with('cliente', 'conversas')->paginate(Input::get('paginate', 10));
// $tarefas = Tarefa::orderBy('date', 'DESC')->with('cliente')->get();
$hoje = date('Y-m-d');
$ontem = Carbon::create(date('Y'), date('m'), date('d'))->subDay();
$amanha = Carbon::create(date('Y'), date('m'), date('d'))->addDay();
$proximo = Carbon::create(date('Y'), date('m'), date('d'))->addDay();
//Igual amanhã?
if ($proximo->isWeekend()) {
$proximo = new Carbon('next monday');
}
$tarefas->pendentes = Tarefa::where('date', '<', $hoje)->where('done', 0)->orderBy('date', 'ASC')->with('cliente', 'conversas')->get();
$tarefas->hoje = Tarefa::where('date', '<', $amanha->startOfDay())->where('date', '>', $ontem)->where('done', 0)->with('cliente', 'conversas')->get();
$tarefas->nextDay = Tarefa::where('done', 0)->where('date', '>=', $amanha)->where('date', '<', $proximo->addDay())->orderBy('date', 'DESC')->with('cliente', 'conversas')->get();
$tarefas->proximas = Tarefa::where('date', '>=', $amanha)->orderBy('date', 'ASC')->where('done', 0)->with('cliente', 'conversas')->get();
$tarefas->concluidas = Tarefa::where('done', 1)->orderBy('updated_at', 'DESC')->with('cliente', 'conversas')->get();
$tarefas->days = $tarefas->groupBy(function ($tarefa) {
return date('Y-m-d', strtotime($tarefa->date));
});
if (Request::ajax()) {
return $tarefas;
}
if (Route::is('tarefas.print')) {
return View::make('tarefas.print', compact('tarefas'));
} else {
return View::make('tarefas.index', compact('tarefas'));
}
}
示例7: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create($member_id)
{
$memberships = Membership::all()->lists('description', 'id');
$membershipsAll = Membership::all();
$member = Member::find($member_id);
$rangeArray = array();
$rangeDates = \App\Affiliation::orderBy('finalization', 'DEC')->where('member_id', $member_id)->where('finalization', '>=', Carbon::now())->get();
foreach ($rangeDates as $range) {
$initiationRange = new Carbon($range->initiation);
$finalizationRange = new Carbon($range->finalization);
$diference = $initiationRange->diffInDays($finalizationRange);
for ($i = 0; $i <= $diference; $i++) {
array_unshift($rangeArray, "'" . $initiationRange->copy()->format('Y-m-d') . "'");
$initiationRange->addDay();
}
}
return view('affiliation.create')->with('memberships', $memberships)->with('membershipsAll', $membershipsAll)->with('member', $member)->with('affiliationRange', $rangeArray);
}
示例8: 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();
}
}
示例9: ignoreNDOW
/**
* Exclude a more complicated method for something like a holiday, e.g.: Memorial Day - "Last Monday in May"
* this could be solved using CoreCallbacks::ignoreNDOW(5, -1, 1)
*
* @param integer $month 1 based index of month, 1 = Jan, 12 = dec
* @param integer $nth Ignore the "nth" $dayOfWeek of the given month (1-6, To get 'LAST' $dayOfWeek, use -1)
* @param integer $dayOfWeek Zero based index day of the week - 0 = Sunday, 6 = Saturday
*
* @return callable
*/
public static function ignoreNDOW($month, $nth, $dayOfWeek)
{
return function (Carbon $context) use($month, $nth, $dayOfWeek) {
if ($context->month !== $month) {
return FALSE;
}
$cmp = new Carbon($context->format('Y-m-') . '01');
/* Set our walker up to the first of the context's month */
$ticks = 0;
/**
* @var $stack Carbon[]
*/
$stack = array();
/* Used to track 'nth' */
for ($i = 0; $i < $context->daysInMonth; $i++) {
if ($cmp->dayOfWeek == $dayOfWeek) {
$stack[] = clone $cmp;
$ticks++;
if ($cmp->eq($context)) {
/* "FIRST" or generic 'nth' */
if ($nth == $ticks) {
return TRUE;
}
}
}
$cmp->addDay();
}
/* For brevity, checking for the -1 anyways */
if ($nth == -1) {
/**
* @var $last Carbon
*/
$last = array_pop($stack);
return $last->eq($context);
}
return FALSE;
};
}
示例10: scopeWhereDateIs
/**
* @param Carbon $date
* @return Builder
*/
public function scopeWhereDateIs(Builder $q, Carbon $date)
{
return $q->where('start_date', '>=', $date->toDateTimeString())->where('start_date', '<', $date->addDay()->toDateTimeString());
}
示例11: getDeadLineDifference
public function getDeadLineDifference(Info $info, Carbon $f_deadline, Carbon $l_deadline)
{
// Get first and last deadlines difference in days
$days = $f_deadline->diffInDays($l_deadline);
$c = 0;
for ($m = 0; $m < $days; $m++) {
$current = $f_deadline->addDay(1);
// If the day after first deadline is not Saturday or Sunday, count as 1 working day
if ($current->dayOfWeek != Carbon::SATURDAY && $current->dayOfWeek != Carbon::SUNDAY) {
$c += 1;
}
}
return $c;
}
示例12: getEmptyDateRangeData
/**
* Returns an array with the current date and the date minus the number of days specified.
*
* @param array $urls
* @param Carbon $startDate
* @param Carbon $endDate
*
* @return array
*/
private function getEmptyDateRangeData($urls, $startDate, $endDate)
{
$data = [];
// Difference in days
$numberOfDays = $startDate->diffInDays($endDate);
// Create date range array
$range = [];
for ($i = 0; $i < $numberOfDays; $i++) {
$day = $startDate->addDay()->format('U') * 1000;
$range[$day] = 0;
}
// Add ranges to data
foreach ($urls as $url) {
$data[$url] = $range;
}
return $data;
}
示例13: addInsertArrayAmountLimit
/**
* метод вызывается, если в абонементе указано количество занятий
* пробегает по рассписанию и добавляет в массив $_insertArray данные о новых оплаченных занятиях,
* для вставки в базу данных.
* @param array Timetable::find() $timeTableGroups
* @param array PaidEmployment::find() $existEmployments
* @param Carbon $currentDate
* @param Carbon $endDate
*/
private function addInsertArrayAmountLimit($timeTableGroups, $existEmployments, $currentDate, $endDate)
{
while ($endDate->timestamp >= $currentDate->timestamp) {
foreach ($timeTableGroups as $tableRow) {
if ($tableRow['week_day'] == $currentDate->dayOfWeek) {
if ($this->_ticketModel->amount < 1) {
goto amountEnd;
}
$findFlag = false;
foreach ($existEmployments as $employmentRow) {
if ($employmentRow['date'] == $currentDate->toDateString() && $tableRow['id'] == $employmentRow['timetable_id']) {
$findFlag = true;
break;
}
}
if (!$findFlag) {
$this->_insertArray[] = ['date' => $currentDate->toDateString(), 'pay_id' => $this->id, 'timetable_id' => $tableRow['id']];
--$this->_ticketModel->amount;
}
}
}
$currentDate->addDay();
}
amountEnd:
// goto amountEnd
}
示例14: testGetAmountBefore
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::getAmountBefore
*/
public function testGetAmountBefore()
{
// create some accounts:
$expense = FactoryMuffin::create('FireflyIII\\Models\\Account');
// expense
FactoryMuffin::create('FireflyIII\\Models\\Account');
// revenue
$asset = FactoryMuffin::create('FireflyIII\\Models\\Account');
// asset
// transaction type
$withdrawal = FactoryMuffin::create('FireflyIII\\Models\\TransactionType');
// withdrawal
// create five journals with incrementing dates:
$today = new Carbon('2015-01-01');
$journal = null;
for ($i = 0; $i < 5; $i++) {
// create journal:
$journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal');
$journal->transaction_type_id = $withdrawal;
$journal->date = $today;
$journal->save();
// update transactions:
$journal->transactions[0]->amount = -100;
$journal->transactions[0]->account_id = $asset->id;
$journal->transactions[0]->save();
$journal->transactions[1]->amount = 100;
$journal->transactions[1]->account_id = $expense->id;
$journal->transactions[1]->save();
// connect to expense
$today->addDay();
}
$before = $this->object->getAmountBefore($journal, $journal->transactions[1]);
// five transactions, we check the last one, so amount should be 400.
$this->assertEquals(400, $before);
}
示例15: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
// Cliente
$cliente = Cliente::find($id);
$pedidos = Pedido::where('cliente_id', $cliente->id)->orderBy('created_at', 'desc')->with(['fornecedor'])->get();
$conversas = Conversa::where('cliente_id', $cliente->id)->orderBy('created_at', 'desc')->get();
$cliente->pedidos = $pedidos;
$cliente->conversas = $conversas;
if ($cliente) {
$pedidos = $cliente->pedidos();
$tarefas = Tarefa::where('cliente_id', $cliente->id)->paginate(Input::get('perpage', 10));
$tarefas->days = $tarefas->groupBy(function ($tarefa) {
return date('Y-m-d', strtotime($tarefa->start));
});
$hoje = date('Y-m-d');
$ontem = Carbon::create(date('Y'), date('m'), date('d'))->subDay();
$amanha = Carbon::create(date('Y'), date('m'), date('d'))->addDay();
$proximo = Carbon::create(date('Y'), date('m'), date('d'))->addDay();
//Igual amanhã
if ($proximo->isWeekend()) {
$proximo = new Carbon('next monday');
}
$tarefas->pendentes = Tarefa::where('cliente_id', $cliente->id)->where('date', '<', $hoje)->where('done', 0)->orderBy('date', 'DESC')->get();
$tarefas->hoje = Tarefa::where('cliente_id', $cliente->id)->where('date', '<', $amanha->startOfDay())->where('date', '>', $ontem)->where('done', 0)->get();
$tarefas->nextDay = Tarefa::where('cliente_id', $cliente->id)->where('done', 0)->where('date', '>=', $amanha)->where('date', '<', $proximo->addDay())->orderBy('date', 'DESC')->get();
$tarefas->proximas = Tarefa::where('cliente_id', $cliente->id)->where('date', '>=', $amanha->startOfDay())->where('done', 0)->orderBy('date', 'ASC')->get();
$tarefas->concluidas = Tarefa::where('cliente_id', $cliente->id)->where('done', 1)->orderBy('updated_at', 'DESC')->get();
// show the view and pass the cliente to it
return View::make('clientes.show', compact('cliente', 'tarefas'));
//->with( 'pedidos', $cliente->pedidos() );
} else {
$alert[] = ['class' => 'alert-warning', 'message' => 'O cliente que você procura não existe!'];
Session::flash('alerts', $alert);
return Redirect::to('clientes');
}
}