Added helper methods for first and last day of month.

Sub-bookings are now showed in the bookings index view.
This commit is contained in:
Lukas Halbritter
2018-10-01 09:56:55 +02:00
parent 491a6f6153
commit 8f865e9bff
2 changed files with 34 additions and 10 deletions
+28 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
/**
* Returns true with a given percentage.
*
* @param int $prob Probability for true in percent.
@@ -20,7 +20,7 @@ function rand_bool($prob = 50) {
return $rand <= $prob;
}
/*
/**
* Return the formatted string representation of a floatng point number.
*
* The decimal point is a ',', the thousands seperator ist set to '.'.
@@ -34,3 +34,29 @@ function rand_bool($prob = 50) {
function formatAmount(float $amount, $decimals = 2) {
return number_format($amount, $decimals, ',', '.');
}
/**
* Return the string that is the first day of the month, given by the year and
* the month.
*
* @param string $year
* @param string $month
* @return string
*/
function startOfMonth($year, $month) {
return Carbon\Carbon::createFromDate($year, $month)
->startOfMonth()->format('Y-m-d');
}
/**
* Return the string that is the last day of the month, given by the year and
* the month.
*
* @param string $year
* @param string $month
* @return string
*/
function endOfMonth($year, $month) {
return Carbon\Carbon::createFromDate($year, $month)
->endOfMonth()->format('Y-m-d');
}