本文整理汇总了PHP中Carbon\Carbon::lt方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::lt方法的具体用法?PHP Carbon::lt怎么用?PHP Carbon::lt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::lt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($id)
{
$member = Member::find($id);
$birthDate = $member->birthday;
$birthDate = explode("-", $birthDate);
$member->age = Carbon::createFromDate($birthDate[0], $birthDate[1], $birthDate[2])->age;
$meses = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
$dias = array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado");
$currentdate = Carbon::today();
$sumaAffiliations = $member->affiliations->sum('price');
$affiliations = $member->affiliations;
$affiliationActives = \App\Affiliation::orderBy('finalization', 'DEC')->where('member_id', $member->id)->where('finalization', '>=', $currentdate)->get();
$affiliationInactives = \App\Affiliation::orderBy('finalization', 'DEC')->where('member_id', $member->id)->where('finalization', '<', $currentdate)->get();
$member->affiliations = $affiliationActives;
if ($affiliationActives->first() != null) {
$memshipactiva = $affiliationActives->last();
$initiation = new Carbon($memshipactiva->initiation);
$finalization = new Carbon($memshipactiva->finalization);
$corrido = $initiation->diffInDays($currentdate);
if ($initiation->lt($currentdate)) {
$diference = $initiation->diffInDays($finalization);
$porcentaje = $corrido / $diference * 100;
} else {
$porcentaje = 0;
}
$memshipactiva->porcentaje = $porcentaje;
} else {
$memshipactiva = null;
}
$saldo = $sumaAffiliations - $member->payments->sum('amount');
$member->saldo = $saldo;
$member->sumaPagos = $member->payments->sum('amount');
$member->sumaAffiliations = $sumaAffiliations;
if ($member->sumaPagos == 0 and $sumaAffiliations == 0) {
//no tiene pagos ni afiliaciones
$member->difUltimoPago = -1;
} elseif ($member->sumaPagos <= 0 and $sumaAffiliations > 0) {
//no tiene pagos pero si tiene afiliaciones
$fechaUltimoPago = \App\Affiliation::orderBy('created_at', 'asc')->where('member_id', $member->id)->first();
$fechaUltimoPago = new Carbon($fechaUltimoPago->created_at);
$difUltimoPago = $fechaUltimoPago->diffInDays($currentdate);
$member->difUltimoPago = $difUltimoPago;
} elseif ($member->sumaPagos > 0 and $sumaAffiliations > 0) {
// tiene afiliaciones y pagos
$fechaUltimoPago = new Carbon($member->payments->first()->created_at);
$difUltimoPago = $fechaUltimoPago->diffInDays($currentdate);
$member->difUltimoPago = $difUltimoPago;
}
return view('member.show', ['member' => $member, 'meses' => $meses, 'dias' => $dias, 'activa' => $memshipactiva, 'inactivas' => $affiliationInactives]);
}
示例2: shiftEndTime
/**
* @param Carbon $time
* @return Carbon
*/
protected function shiftEndTime($time)
{
if ($time->lt($this->day_shift_end_time)) {
return $this->day_shift_end_time;
}
return $this->night_shift_end_time;
}
示例3: scopeScheduledBetween
function scopeScheduledBetween($q, \Carbon\Carbon $date1 = null, \Carbon\Carbon $date2 = null)
{
if (!$date1 && !$date2) {
return $q;
} elseif (!$date1 || !$date2) {
throw new Exception("Invalid date range", 1);
} else {
if ($date2->lt($date1)) {
$tmp = $date1;
$date1 = $date2;
$date2 = $tmp;
}
return $q->where(function ($q) use($date1, $date2) {
$q->where(function ($q) use($date1, $date2) {
$q->whereNull('departure_until')->where('departure', '>=', $date1)->where('departure', '<=', $date2);
})->orWhere(function ($q) use($date1, $date2) {
$q->whereNotNull('departure_until')->where(function ($q) use($date1, $date2) {
$q->where(function ($q) use($date1, $date2) {
$q->where('departure', '<=', $date1)->where('departure_until', '>=', $date1);
})->orWhere(function ($q) use($date1, $date2) {
$q->where('departure', '>=', $date1)->where('departure_until', '<=', $date2);
})->orWhere(function ($q) use($date1, $date2) {
$q->where('departure', '>=', $date1)->where('departure', '<=', $date2)->where('departure_until', '>=', $date2);
})->orWhere(function ($q) use($date1, $date2) {
$q->where('departure', '<=', $date1)->where('departure_until', '>=', $date2);
});
});
});
});
}
}
示例4: eventHasPassed
private function eventHasPassed(Slot $slot)
{
$start_date = new Carbon($slot->start_date);
if ($start_date->lt(Carbon::now())) {
return true;
}
return false;
}
示例5: filter
/**
* Datetime exact match check as well as between check
* @param string $content
* @param string $search
* @param string $type
* @return bool
*/
public function filter($content, $search, $type)
{
$search = is_array($search) ? $search : [$search];
$search = array_map(function ($searchValue) {
return is_a($searchValue, Carbon::class) ? $searchValue : new Carbon($searchValue);
}, $search);
$current = new Carbon($content);
switch ($type) {
case 'in':
return $current->gte($search[0]) && $current->lt($search[1]);
break;
default:
return $current->eq($search[0]);
}
}
示例6: validateBeforeField
public function validateBeforeField($attribute, $value, $parameters)
{
$this->requireParameterCount(1, $parameters, 'before_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->lt($value2);
}
示例7: 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;
}
示例8: exportReport
/**
* Export report to xls or pdf
* @param unknown $type
* @param unknown $report
*/
public function exportReport($type, $report, $offset = 0)
{
if (!in_array($type, $this->validExportTypes)) {
return;
}
ini_set('memory_limit', '-1');
set_time_limit(0);
$records = [];
$columns = [];
$theadRaw = '';
$rows = [];
$summary = [];
$header = '';
$filters = [];
$previous = [];
$current = [];
$currentSummary = [];
$previousSummary = [];
$filename = 'Report';
$scr = '';
$area = '';
$prepare = '';
$fontSize = '12px';
$textSize = '12px';
$vaninventory = false;
$salesSummary = false;
$limit = in_array($type, ['xls', 'xlsx']) ? config('system.report_limit_xls') : config('system.report_limit_pdf');
$offset = $offset == 1 || !$offset ? 0 : $offset - 1;
switch ($report) {
case 'salescollectionreport':
$columns = $this->getTableColumns($report, $type);
$prepare = $this->getPreparedSalesCollection();
$prepare->orderBy('collection.invoice_date', 'desc');
$collection1 = $prepare->get();
$referenceNum = [];
$invoiceNum = [];
foreach ($collection1 as $col) {
$referenceNum[] = $col->reference_num;
$invoiceNum[] = $col->invoice_number;
}
array_unique($referenceNum);
array_unique($invoiceNum);
$except = $referenceNum ? ' AND tas.reference_num NOT IN(\'' . implode("','", $referenceNum) . '\') ' : '';
$except .= $invoiceNum ? ' AND coltbl.invoice_number NOT IN(\'' . implode("','", $invoiceNum) . '\') ' : '';
$prepare = $this->getPreparedSalesCollection2(false, $except);
$collection2 = $prepare->get();
$collection = array_merge((array) $collection1, (array) $collection2);
$current = $this->formatSalesCollection($collection);
$currentSummary = [];
if ($current) {
$currentSummary = $this->getSalesCollectionTotal($current);
}
$current = array_splice($current, $offset, $limit);
$hasDateFilter = false;
if ($this->request->has('collection_date_from')) {
$from = new Carbon($this->request->get('collection_date_from'));
$endOfWeek = (new Carbon($this->request->get('collection_date_from')))->endOfWeek();
$to = new Carbon($this->request->get('collection_date_to'));
$hasDateFilter = true;
}
if ($hasDateFilter && $from->eq($to)) {
$scr = $this->request->get('salesman') . '-' . $from->format('mdY');
} elseif ($hasDateFilter && $from->lt($to) && $to->lte($endOfWeek) && $to->diffInDays($from) < 8) {
$golive = new Carbon(config('system.go_live_date'));
$numOfWeeks = $to->diffInWeeks($golive) + 1;
$code = str_pad($numOfWeeks, 5, '0', STR_PAD_LEFT);
$scr = $this->request->get('salesman') . '-' . $code;
}
$prepareArea = $this->getPreparedSalesmanList($this->request->get('salesman'));
$resultArea = $prepareArea->first();
$area = $resultArea ? $resultArea->area_name : '';
$pdf = !in_array($type, ['xls', 'xlsx']);
$rows = $this->getSalesCollectionSelectColumns($pdf);
$header = 'Sales & Collection Report';
$filters = $this->getSalesCollectionFilterData(true);
$filename = 'Sales & Collection Report';
$vaninventory = true;
$fontSize = '7px';
break;
case 'salescollectionposting':
$columns = $this->getTableColumns($report);
$prepare = $this->getPreparedSalesCollectionPosting();
$collection1 = $prepare->get();
$referenceNum = [];
foreach ($collection1 as $col) {
$referenceNum[] = $col->reference_num;
}
array_unique($referenceNum);
$except = $referenceNum ? ' AND tas.reference_num NOT IN(\'' . implode("','", $referenceNum) . '\') ' : '';
$prepare = $this->getPreparedSalesCollectionPosting2($except);
$collection2 = $prepare->get();
$collection = array_merge((array) $collection1, (array) $collection2);
$invoices = [];
foreach ($collection as $col) {
$invoices[] = $col->invoice_number;
//.........这里部分代码省略.........
示例9: contains
public function contains(Carbon $date_time)
{
return $date_time->gt($this->after) && $date_time->lt($this->before);
}
示例10: getRaidTuesdayCountdown
public function getRaidTuesdayCountdown()
{
if (Carbon::now('America/Chicago')->isSameDay(new Carbon('Tuesday 4am CST', 'America/Chicago'))) {
$raidtuesday = new Carbon('Tuesday 4am CST', 'America/Chicago');
} else {
$raidtuesday = new Carbon('next Tuesday 4 AM', 'America/Chicago');
}
if ($raidtuesday->lt(Carbon::now('America/Chicago'))) {
return \Response::json(['error' => false, 'msg' => 'Today is Raid Tuesday! Get your raids in!']);
} else {
$countdown = $raidtuesday->diffInSeconds(Carbon::now('America/Chicago'));
$countdown = Text::timeDuration($countdown);
return \Response::json(['error' => false, 'msg' => $countdown]);
}
}
示例11: needsRefresh
/**
* @return bool
*/
public function needsRefresh()
{
return $this->dateExpires->lt(Carbon::now());
}
示例12: getMinDiff
private function getMinDiff(Carbon $time1, Carbon $time2)
{
if ($time2->lt($time1)) {
// if timeout is less than breakout
$time2->addDay();
}
// add 1 day
return $time2->diffInMinutes($time1);
}