1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if (!function_exists('random_password')) { |
4
|
|
|
/** |
5
|
|
|
* Generate random password. |
6
|
|
|
* |
7
|
|
|
* @param int $length |
8
|
|
|
* @param string $availableSets |
9
|
|
|
* |
10
|
|
|
* @return string |
11
|
|
|
*/ |
12
|
|
|
function random_password(int $length = 9, string $availableSets = 'luds') |
13
|
|
|
{ |
14
|
|
|
return app('helper')->randomPassword($length, $availableSets); |
|
|
|
|
15
|
|
|
} |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
if (!function_exists('persian_slug')) { |
19
|
|
|
/** |
20
|
|
|
* Generate persian slug. |
21
|
|
|
* |
22
|
|
|
* @param string $string |
23
|
|
|
* @param string $separator |
24
|
|
|
* |
25
|
|
|
* @return false|mixed|string|string[]|null |
26
|
|
|
*/ |
27
|
|
|
function persian_slug(string $string, string $separator = '-') |
28
|
|
|
{ |
29
|
|
|
return app('helper')->persianSlug($string, $separator); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
if (!function_exists('fa_to_en_nums')) { |
34
|
|
|
/** |
35
|
|
|
* Convert all Persian(Farsi) numbers to English. |
36
|
|
|
* |
37
|
|
|
* @param string $number |
38
|
|
|
* |
39
|
|
|
* @return mixed |
40
|
|
|
*/ |
41
|
|
|
function fa_to_en_nums(string $number) |
42
|
|
|
{ |
43
|
|
|
return app('helper')->faToEnNums($number); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if (!function_exists('remove_comma')) { |
48
|
|
|
/** |
49
|
|
|
* Remove comma's from value. |
50
|
|
|
* |
51
|
|
|
* @param string $value |
52
|
|
|
* |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
function remove_comma(string $value) : string |
56
|
|
|
{ |
57
|
|
|
return app('helper')->removeComma($value); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if (!function_exists('to_gregorian')) { |
62
|
|
|
/** |
63
|
|
|
* Convert jalali date to gregorian date. |
64
|
|
|
* |
65
|
|
|
* @param string $jDate |
66
|
|
|
* |
67
|
|
|
* @return null|string |
68
|
|
|
*/ |
69
|
|
|
function to_gregorian(string $jDate) |
70
|
|
|
{ |
71
|
|
|
return app('helper')->toGregorian($jDate); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
if (! function_exists('mb_json_encode')) { |
76
|
|
|
/** |
77
|
|
|
* json_encode() for multibyte characters |
78
|
|
|
* |
79
|
|
|
* @param mixed |
80
|
|
|
* |
81
|
|
|
* @return null|string |
82
|
|
|
*/ |
83
|
|
|
function mb_json_encode($input) { |
84
|
|
|
return preg_replace_callback('/\\\\u([0-9a-zA-Z]{4})/', function ($matches) { |
85
|
|
|
return mb_convert_encoding(pack('H*',$matches[1]), 'UTF-8','UTF-16'); |
86
|
|
|
}, |
87
|
|
|
json_encode($input, JSON_UNESCAPED_UNICODE) |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|