title: Refactor repetitive query on Laravel
body: <p>Can't wrap my head around this, what's the best way to refactor this?</p>
  <pre><code>private function generateUsername($first, $last)
      {
          $un1 = Str::lower($first . $last);
          $un2 = Str::lower($first . '.' . $last);
          $un3 = Str::lower($first . '-' . $last);
          $un4 = Str::lower($first . '_' . $last);
  
          if (!User::where('username', $un1)-&gt;first()) {
              return $un1;
          } elseif (!User::where('username', $un2)-&gt;first()) {
              return $un2;
          } elseif (!User::where('username', $un3)-&gt;first()) {
              return $un3;
          } elseif (!User::where('username', $un4)-&gt;first()) {
              return $un4;
          } else {
              return $un1 . rand(1, 9);
          }
      }
  </code></pre>
  <p>seems very repetitive, any way i can just have one line function to look if the username already exists? it's not for validation, i want to automatically generate their username based on their full name</p>