| Conditions | 3 |
| Paths | 1 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | protected static function boot() |
||
| 15 | { |
||
| 16 | parent::boot(); |
||
| 17 | |||
| 18 | static::creating(function ($link) { |
||
| 19 | if (config('linkstack.disable_random_link_ids') != 'true') { |
||
| 20 | $numberOfDigits = config('linkstack.link_id_length') ?? 9; |
||
| 21 | |||
| 22 | $minIdValue = 10**($numberOfDigits - 1); |
||
| 23 | $maxIdValue = 10**$numberOfDigits - 1; |
||
| 24 | |||
| 25 | do { |
||
| 26 | $randomId = rand($minIdValue, $maxIdValue); |
||
| 27 | } while (Link::find($randomId)); |
||
| 28 | |||
| 29 | $link->id = $randomId; |
||
| 30 | } |
||
| 34 |