create folder Helpers in app directory
create file StringHelper.php in app\Helpers
<?php
namespace App\Helpers;
class StringHelper
{
public static function getCleanString($string)
{
//remove unnecessary chars
$string = str_replace(['-', ' '], '', $string);
return str_slug($string);
}
}
add any simple function in this class as static.
when you need a different helper, create new class for example YoutubeHelper.php and add there stuff you need.
\App\Helpers\StringHelper::getCleanString($name)
No comments:
Post a Comment