title: How to ensure unique ID in Laravel Blade?
body: <p>Let's imagine I have a blade component such as: </p>
  
  <pre><code>&lt;input type="text" id="foo" name="{{$name}}"/&gt;
  &lt;script&gt;
  $('#foo').whatever
  &lt;/script&gt;
  </code></pre>
  
  <p><a href="https://www.urbandictionary.com/define.php?term=IRL" rel="nofollow noreferrer">IRL</a>, this component is far more complicated. You could imagine a long form with plenty of fields with generic names like <code>name</code>, <code>description</code>, <code>owner</code>...</p>
  
  <p>Then I use this component multiple times, again I propose a <code>foreach</code> but we could imagine something else in which I cannot use an iterator to provide an id to my component:</p>
  
  <pre><code>@foreach($items as $item)
      @component('foo')
      @endcomponent
  @endforeach
  </code></pre>
  
  <p>How can I ensure the uniqueness of the <code>id</code>?</p>
  
  <p>One perhaps bad solution would be to use a local variable: </p>
  
  <pre><code>@php($id = uniqid())
  &lt;input type="text" id="{{$id}}" name="{{$name}}"/&gt;
  &lt;script&gt;
  $('#{{$id}}').change(whatever)
  &lt;/script&gt;
  </code></pre>
  
  <p>Is there a better way?</p>