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:
+28
-2
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user