/
username_generator.php
148 lines (125 loc) · 3.45 KB
/
username_generator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
use TaylorNetwork\UsernameGenerator\Drivers\EmailDriver;
use TaylorNetwork\UsernameGenerator\Drivers\NameDriver;
return [
/*
* Should the username generated be unique?
*/
'unique' => true,
/*
* The minimum length of the username.
*
* Set to 0 to not enforce
*/
'min_length' => 0,
/*
* Want to throw a UsernameTooShort exception when too short?
*/
'throw_exception_on_too_short' => false,
/*
* The maximum length of the username.
*
* Set to 0 to not enforce
*/
'max_length' => 0,
/*
* Want to throw a UsernameTooLong exception when too long?
*/
'throw_exception_on_too_long' => false,
/*
* Convert the case of the generated username
*
* Any of the string case functions from Illuminate\Support\Str
*
* 'lower', 'upper', 'title', 'ucfirst' or 'mixed' to ignore
*/
'case' => 'lower',
/*
* Convert spaces in username to a separator
*/
'separator' => '',
/*
* Model to check if the username is unique to.
*
* This is only used if unique is true
*/
'model' => \App\Models\User::class,
/*
* Database field to check and store username
*/
'column' => 'username',
/*
* Validate characters using RegEx
*/
'validate_characters' => true,
/*
* Allowed characters from the original unconverted text
*
* You can add additional character sets here or by property
* '\p{Cyrillic}\p{Latin}\s ' would allow cyrillic and latin characters
*
*/
'allowed_characters' => 'a-zA-Z\s ',
/*
* Character encoding
*/
'encoding' => 'UTF-8',
/*
* Convert all entered text to ASCII?
*/
'convert_to_ascii' => true,
/*
* Language
*
* This is used when converting to ASCII, ignore if convert_to_ascii is false.
*/
'language' => 'en',
/*
* Run the generator even if the username was provided by the user?
* Only used with GeneratesUsernames Trait.
* This would be useful to maintain congruency in usernames even
* if someone enters their own. If set to false, when the username
* field is not empty then the generator will not run.
*/
'generate_entered_username' => true,
/*
* Prefer using database REGEXP function?
*
* LIKE function will be used as a backup on failure.
*/
'prefer_regexp' => false,
/*
* Field Map
*
* This is really only used when using generateFor().
*
* If the default "name" field for your model is not "name" you can create a
* field map here. When looking for the "name" field, if not found, will check
* the "fullName" field. You can have the same effect by adding a "name" attribute
* to the model in question (ie. getNameAttribute)
*
* 'field_map' => [
* 'name' => 'fullName',
* ],
*/
'field_map' => [],
/*
* Max number of attempts to perform when trying to make a username unique when the
* fallback method is used.
*/
'increment_max_attempts' => 100,
/*
* Loaded drivers for converting to a username
*/
'drivers' => [
'name' => NameDriver::class,
'email' => EmailDriver::class,
],
/*
* Add your own adjective and nouns word lists here if don't want to use the default
*/
'dictionary' => [
'adjectives' => [],
'nouns' => [],
],
];