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()
62
62
parent ::boot ();
63
63
64
64
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 ;
67
70
68
- $ minIdValue = 10 **($ numberOfDigits - 1 );
69
- $ maxIdValue = 10 **$ numberOfDigits - 1 ;
71
+ $ minIdValue = 10 **($ numberOfDigits - 1 );
72
+ $ maxIdValue = 10 **$ numberOfDigits - 1 ;
70
73
71
- do {
72
- $ randomId = rand ($ minIdValue , $ maxIdValue );
73
- } while (User::find ($ randomId ));
74
+ do {
75
+ $ randomId = rand ($ minIdValue , $ maxIdValue );
76
+ } while (User::find ($ randomId ));
74
77
75
- $ user ->id = $ randomId ;
76
- }
78
+ $ user ->id = $ randomId ;
79
+ }
80
+ }
77
81
});
78
82
}
79
83
}
You can’t perform that action at this time.
0 commit comments