jeudi 19 novembre 2015

Passing a function from controller to view

I have a function that take in a string, and convert it to a Mac Address format.

    function mac_adress($str){
        $end = substr($str, -12);
        $chunks = str_split($end, 2);
        $result = implode(':', $chunks);
        return $result;
    }

I want pass function to my view so I can just call it like this

$str = 836997595163;

{!!mac_adress($str)!!} //83:69:97:59:51:63

I have multiple views that need this functionally, and I'm trying to avoid place them in every single one of my blade file.

How can I do that ?

Is it even possible ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire