mein-sterntours/app/helpers.php
Kevin Adametz 881fc84207 08 2024
2024-08-05 11:58:09 +02:00

111 lines
No EOL
2.9 KiB
PHP

<?php
if (! function_exists('make_old_url')) {
function make_old_url($path)
{
$path = trim($path, "/");
return config('app.old_url')."/".$path;
}
}
if (! function_exists('make_v2_url')) {
function make_v2_url($path)
{
$path = trim($path, "/");
return config('app.url_v2')."/".$path;
}
}
if (! function_exists('_format_date')) {
function _format_date($date, $to = 'date')
{
return $date ? \App\Services\Util::_format_date($date, $to) : null;
}
}
if (! function_exists('_number_format')) {
function _number_format($number, $dec = 2)
{
return $number ? \App\Services\Util::_number_format($number, $dec) : null;
}
}
if (! function_exists('_reformat_date')) {
function _reformat_date($date, $to = 'date')
{
return $date ? \App\Services\Util::_reformat_date($date, $to) : null;
}
}
if (! function_exists('array_to_json')) {
function array_to_json($value)
{
return htmlspecialchars(json_encode($value));
}
}
if (! function_exists('last_array_element')) {
function last_array_element($value)
{
$e = explode("/", $value);
if(is_array($e)){
return end($e);
}
return $e;
}
}
if (! function_exists('pre_slug')) {
function pre_slug($value)
{
return strtr($value, ["Ä" => "ae", "Ö" => "oe", "Ü" => "ue", "ä" => "ae", "ö" => "oe", "ü" => "ue", "ß"=>"ss"]);
}
}
if (! function_exists('get_active_badge')) {
function get_active_badge($active, $tooltip = false, $pos = "top")
{
if($tooltip){
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.$tooltip.'"';
}
return $active ? '<span class="badge badge-pill badge-success" '.$tooltip.'><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger" '.$tooltip.'><i class="fa fa-times"></i></span>';
}
}
if (! function_exists('get_switcher_input')) {
function get_switcher_input($active = false, $name = "", $label = "")
{
return '<label class="switcher">
<input type="checkbox" name="'.$name.'" class="switcher-input" '.($active ? 'checked="checked"' : '').'>
<span class="switcher-indicator">
<span class="switcher-yes"></span>
<span class="switcher-no"></span>
</span>
<span class="switcher-label">'.$label.'</span>
</label>';
}
}
if (! function_exists('get_file_last_time')) {
function get_file_last_time($value)
{
if (file_exists($value)) {
return filemtime($value);
}
return date("Ymd-i", time());
}
}
if (! function_exists('my_count')) {
function my_count($value)
{
if ($value && is_array($value)) {
return count($value);
}
return 0;
}
}