Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. <?php
  2.  
  3. public function generatePath()
  4. {
  5. $attempts = 5;
  6.  
  7. for ($i = 0; $ i<= $attempts; $i++) {
  8. $path = 'public/photos/'. Str::random(40). '.jpg';
  9.  
  10. if (!Storage::exists($path) {
  11. return $path;
  12. }
  13. }
  14.  
  15. throw new Exception('Can\'t find a file name');
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement