public function monthlyLogs(Carbon $date, $branch) { $arr = []; $fr = $date->firstOfMonth(); $to = $date->copy()->lastOfMonth(); $data = $this->aggregateDailyLogs($fr, $to, $branch->id); for ($i = 0; $i < $date->daysInMonth; $i++) { $date = $fr->copy()->addDays($i); $filtered = $data->filter(function ($item) use($date) { return $item->filedate->format('Y-m-d') == $date->format('Y-m-d') ? $item : null; }); $b = $filtered->first(); if (!is_null($b)) { $e = file_exists(config('filesystems.disks.backup.' . app()->environment() . '.root') . $branch->code . DS . $b->year . DS . $b->filedate->format('m') . DS . $b->filename); } else { $e = 0; } array_push($arr, ['date' => $date, 'backup' => $b, 'exist' => $e]); } return $arr; }
echo $dtBerlin->toDateTimeString() . "\n"; echo $dtBerlin->toDayDateTimeString() . "\n"; echo $dtBerlin->toRfc1036String() . "\n"; echo $dtBerlin->toAtomString() . "\n"; echo $dtBerlin->toCookieString() . "\n"; echo $dtBerlin->toRssString() . "\n"; $dtBerlin->setToStringFormat('l jS \\of F Y'); echo $dtBerlin . "\n"; echo (int) $dtBerlin->isLeapYear() . "\n"; // is* range of functions test printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no"); printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no"); printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no"); printf("Is a leap year? %s\n", $dtBerlin->isLeapYear() ? "yes" : "no"); // first and last of the month printf("First of the month %s\n", $dtBerlin->firstOfMonth()); printf("Last of the month %s\n", $dtBerlin->lastOfMonth()); // nthOf* function test printf("Start of the month %s\n", $dtBerlin->startOfMonth()); printf("End of the month %s\n", $dtBerlin->endOfMonth()); printf("End of the decade %s\n", $dtBerlin->endOfDecade()); // Date manipulation print $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3); print $dtBerlin->subMonths(8)->subHours(7); // Find UK Bank Holidays $dtLondon = CitcoCarbon::today('Europe/London'); list($date, $name) = each($dtLondon->nextBankHoliday()); printf("The next bank holiday is %s on %s\n", $name, $date); foreach ($dtLondon->getBankHolidays([2016, 2017]) as $date => $name) { printf("The next bank holiday is %s on %s\n", $name, $date); }
echo $dtBerlin->toDateTimeString() . "\n"; echo $dtBerlin->toDayDateTimeString() . "\n"; echo $dtBerlin->toRfc1036String() . "\n"; echo $dtBerlin->toAtomString() . "\n"; echo $dtBerlin->toCookieString() . "\n"; echo $dtBerlin->toRssString() . "\n"; $dtBerlin->setToStringFormat('l jS \\of F Y'); echo $dtBerlin . "\n"; echo (int) $dtBerlin->isLeapYear() . "\n"; // is* range of functions test echo "Is yesterday? " . ($dtBerlin->isYesterday() ? "yes" : "no") . PHP_EOL; echo "Is a Thursday? " . ($dtBerlin->isThursday() ? "yes" : "no") . PHP_EOL; echo "Is in the future? " . ($dtBerlin->isFuture() ? "yes" : "no") . PHP_EOL; echo "Is a leap year? " . ($dtBerlin->isLeapYear() ? "yes" : "no") . PHP_EOL; // first and last of the month echo "First of the month " . $dtBerlin->firstOfMonth() . PHP_EOL; echo "Last of the month " . $dtBerlin->lastOfMonth() . PHP_EOL; // nthOf* function test echo "Start of the month ", $dtBerlin->startOfMonth() . PHP_EOL; echo "End of the month ", $dtBerlin->endOfMonth() . PHP_EOL; echo "End of the decade ", $dtBerlin->endOfDecade() . PHP_EOL; // Date manipulation echo $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3) . PHP_EOL; echo $dtBerlin->subMonths(8)->subHours(7) . PHP_EOL; // Find UK Bank Holidays $dtLondon = CitcoCarbon::today('Europe/London'); list($date, $name) = each($dtLondon->nextBankHoliday()); printf("The next bank holiday is %s on %s\n", $name, $date); foreach ($dtLondon->getBankHolidays([2016, 2017]) as $date => $name) { printf("The next bank holiday is %s on %s\n", $name, $date); }
/** * @param Carbon $date * @return \Illuminate\Support\Collection */ public function findOfMonth(Carbon $date) { $startDate = $date->firstOfMonth()->format(MYSQL_DATE_FORMAT); $endDate = $date->lastOfMonth()->format(MYSQL_DATE_FORMAT); $schedules = $this->findByDateInterval($startDate, $endDate); return $schedules; }
/** * Count total Contracts * * @param string $date * @return contract */ public function countContractTotal($date = '') { switch ($date) { case 'today': $dateFormat = $this->carbon->today()->toDateString(); break; case 'yesterday': $dateFormat = $this->carbon->yesterday()->toDateString(); break; case 'this_month': $dateFormat = [$this->carbon->firstOfMonth()->toDateString(), $this->carbon->now()->toDateString()]; break; case 'last_month': $dateFormat = [$this->carbon->now()->subMonth(1)->firstOfMonth()->toDateString(), $this->carbon->now()->subMonth(1)->endOfMonth()->toDateString()]; break; default: $dateFormat = ''; break; } return $this->contract->countTotal($dateFormat); }