Require this package with composer:
composer require shetabit/helper
Laravel >=5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php:
Shetabit\Helper\HelperServiceProvider::class,
If you want to use the facade, add this to your facades in app.php:
'Helper' => Shetabit\Helper\Facades::class,
- Random Password
- Persian Slug
- Persian To English Numbers
- Remove Comma
- Jalali To Gregorian
- Mb Json Encode
Generate random password. $availableSets parameter: 'l' => lowercase alphabets, 'u' => uppercase, 'd' => digits, 's' => symbols
...randomPassword(int $length = 9, string $availableSets = 'luds');
Helper::randomPassword(); //Output: '9nZnE%3wB'
//Or
random_password(); //Output: '9nZnE%3wB'
Generate persian slug.
...persianSlug(string $string, string $separator = '-')
Helper::persianSlug('ایران سرای من'); //Output: 'ایران-سرای-من'
//Or
persian_slug('ایران سرای من'); //Output: 'ایران-سرای-من'
Convert all Persian(Farsi) numbers to English.
...faToEnNums(string $number)
Helper::faToEnNums('۵۶89٤٦'); //Output: '568946'
//Or
fa_to_en_nums('۵۶89٤٦'); //Output: '568946'
Remove comma's from value.
...removeComma(string $value)
Helper::removeComma('5000,000'); //Output: '5000000'
//Or
remove_comma('5000,000') //Output: '5000000'
Convert jalali date to gregorian date.
...toGregorian(string $jDate)
Helper::toGregorian('1397/12/11'); //Output: '2018/3/2'
//Or
to_gregorian('1397/12/11') //Output: '2018/3/2'
json_encode() for multibyte characters.
...mbJsonEncode(array $input)
Helper::mbJsonEncode(['name' => 'علی', 'family' => 'حمزه ای']); //Output: '{"name":"علی","family":"حمزه ای"}'
//Or
mb_json_encode(['name' => 'علی', 'family' => 'حمزه ای']) //Output: '{"name":"علی","family":"حمزه ای"}'