moses
1458
11
Laravel

Where I put my custom functions to be accessed in view (laravel 5.3)?

Posted 2 years ago by moses

My function is like this :

function romanic_number($integer, $upcase = true) 
{ 
    $table = array('M'=>1000, 'CM'=>900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1); 
    $return = ''; 
    while($integer > 0) 
    { 
        foreach($table as $rom=>$arb) 
        { 
            if($integer >= $arb) 
            { 
                $integer -= $arb; 
                $return .= $rom; 
                break; 
            } 
        } 
    } 

    return $return; 
} 

I want in view, I can accessing like this :

{{ romanic_number(2) }}

The result : II

Where I put my custom functions to be accessed in view?

I try put my custom functions in controller, but it's failed

Please sign in or create an account to participate in this conversation.