<?php

if (! function_exists('make_old_url')) {
    function make_old_url($path)
    {
        return config('app.old_url').$path;
    }
}


if (! function_exists('make_old_url')) {
    function make_old_url($path)
    {
        return config('app.old_url').$path;
    }
}

if (! function_exists('get_file_last_time')) {
    function get_file_last_time($value)
    {
        if (file_exists($value)) {
            return filemtime($value);
        }
        return date("Ymd-is", time());
    }
}

if (! function_exists('get_user_attr')) {
    function get_user_attr($key){
        if ($user = Auth::user()) {
            return $user->getSetting($key);
        }
        return null;
    }
}

if (! function_exists('set_user_attr')) {
    function set_user_attr($key, $value){
        if ($user = Auth::user()) {
            return $user->setSetting([$key => $value]);
        }
        return null;
    }
}

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('formatNumber')) {
    function formatNumber($number, $dec=2)
    {
        return !$number ? $number : Util::formatNumber($number, $dec);
    }
}

if (! function_exists('reFormatNumber')) {
    function reFormatNumber($number)
    {
        return !$number ? $number : Util::reFormatNumber($number);
    }
}


