initial commit
This commit is contained in:
43
src/helpers/global_functions.php
Normal file
43
src/helpers/global_functions.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
if (! function_exists('snake2Title')) {
|
||||
/**
|
||||
* Convert a snake case string to a title with spaces
|
||||
* and every word capitalized.
|
||||
*
|
||||
* @param string $stakeSlug A snake case string, commonly a slug
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function snake2Title(string $snakeSlug): string
|
||||
{
|
||||
$output = preg_replace('/\_/', ' ', $snakeSlug);
|
||||
return ucwords($output);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('carbon')) {
|
||||
function carbon(?string $timestring = null)
|
||||
{
|
||||
$carbon = Carbon\Carbon::now(session('timezone_name'));
|
||||
if (! empty($timestring)) {
|
||||
$carbon = Carbon\Carbon::parse($timestring, session('timezone_name'));
|
||||
}
|
||||
return $carbon;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('jddayofweek')) {
|
||||
function jddayofweek(?int $intDay = null, int $mode = 0)
|
||||
{
|
||||
if (is_null($intDay)) {
|
||||
$intDay = date('l');
|
||||
}
|
||||
|
||||
if ($mode === 0) {
|
||||
return $intDay;
|
||||
}
|
||||
|
||||
return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][$intDay];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user