title: Laravel: Generate random unique token
body: <p>I have a table in my database called <code>keys</code> that has this structure:</p>
  
  <pre><code>id | user_id | token_id | token_key
  </code></pre>
  
  <p>Every time a user logs into my site, I need to generate a new <code>token_id</code> and <code>token_key</code> set for that user. How can I generate a random token for both the <code>token_id</code> and the <code>token_key</code> while keeping the two values unique?</p>
  
  <p>For example, if:</p>
  
  <ul>
  <li><code>token_id</code> is <code>dfbs98641aretwsg</code>, </li>
  <li><code>token_key</code> is <code>sdf389dxbf1sdz51fga65dfg74asdf</code></li>
  </ul>
  
  <p>Meaning:</p>
  
  <pre><code>id | user_id | token_id         | token_key
  1  | 1       | dfbs98641aretwsg | sdf389dxbf1sdz51fga65dfg74asdf
  </code></pre>
  
  <p>There can be no other row in the table with that combination of tokens. How can I do this?</p>