| Conditions | 4 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 60 | protected static function boot() |
||
| 61 | { |
||
| 62 | parent::boot(); |
||
| 63 | |||
| 64 | static::creating(function ($user) { |
||
| 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; |
||
| 70 | |||
| 71 | $minIdValue = 10**($numberOfDigits - 1); |
||
| 72 | $maxIdValue = 10**$numberOfDigits - 1; |
||
| 73 | |||
| 74 | do { |
||
| 75 | $randomId = rand($minIdValue, $maxIdValue); |
||
| 76 | } while (User::find($randomId)); |
||
| 77 | |||
| 78 | $user->id = $randomId; |
||
| 79 | } |
||
| 84 |