mercredi 2 décembre 2015

laravel where add class to be available in Controller and Blade

as the topic, i have got a problem. It means I do not know where i should add class and can use it in my Controller and Blade template.

class myHelper {

    function clear_alias($string)
    {
        $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
        $string = strtolower($string);
        $string = strtr($string, array('&' => '_', '"' => '-', '&'.'#039;' => '-', '<' => '-', '>' => '-', '\'' => ''));
        $string = preg_replace('/^[^a-z0-9]{0,}(.*?)[^a-z0-9]{0,}$/si', '\\1', $string);
        $string = preg_replace('/[^a-z0-9\-]/', '-', $string);
        $string = preg_replace('/[\-]{2,}/', '-', $string);
        return $string;
    }

    function cut_text($string,$char=100)
    {
        $string = strip_tags($string);

        if (strlen($string) > $char)
        {
            $string=substr($string, 0, $char);
            for ($a=strlen($string)-1;$a>=0;$a--)
            {
                if ($string[$a]==" ")
                {
                    $string=substr($string, 0, $a)."...";
                    break;
                };
            };
        };
        return $string;
    }
}

Thanks for help



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire