File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -62,18 +62,22 @@ protected static function boot()
6262 parent ::boot ();
6363
6464 static ::creating (function ($ user ) {
65- if (config ('linkstack.disable_random_user_ids ' ) != 'true ' ) {
66- $ numberOfDigits = config ('linkstack.user_id_length ' ) ?? 6 ;
65+ if (config ('linkstack.disable_random_user_ids ' ) != 'true ' ) {
66+ if (is_null (User::first ())) {
67+ $ user ->id = 1 ;
68+ } else {
69+ $ numberOfDigits = config ('linkstack.user_id_length ' ) ?? 6 ;
6770
68- $ minIdValue = 10 **($ numberOfDigits - 1 );
69- $ maxIdValue = 10 **$ numberOfDigits - 1 ;
71+ $ minIdValue = 10 **($ numberOfDigits - 1 );
72+ $ maxIdValue = 10 **$ numberOfDigits - 1 ;
7073
71- do {
72- $ randomId = rand ($ minIdValue , $ maxIdValue );
73- } while (User::find ($ randomId ));
74+ do {
75+ $ randomId = rand ($ minIdValue , $ maxIdValue );
76+ } while (User::find ($ randomId ));
7477
75- $ user ->id = $ randomId ;
76- }
78+ $ user ->id = $ randomId ;
79+ }
80+ }
7781 });
7882 }
7983}
You can’t perform that action at this time.
0 commit comments