title: Two links appears for one user weirdly - Laravel models
body: <p>I have a many-to-many relationship between my User and Wallet models.</p>
  <p><strong>Wallet Model</strong></p>
  <pre><code>public function users() 
  {
      return $this-&gt;belongsToMany(User::class, 'user_wallet', 'user_id', 'wallet_id');
  }
  </code></pre>
  <p><strong>User Model</strong></p>
  <pre><code>public function wallets() 
  {
      return $this-&gt;belongsToMany(Wallet::class, 'user_wallet', 'user_id', 'wallet_id')-&gt;withPivot('balance');;
  }
  </code></pre>
  <p>Then in my Blade file, I tried the following.</p>
  <pre><code>@forelse($user-&gt;wallets as $wallet)
      &lt;tr&gt;
          &lt;td&gt;
              {{ $wallet-&gt;name }}
          &lt;/td&gt;
          &lt;td&gt;
              {{ $wallet-&gt;pivot-&gt;balance }}
          &lt;/td&gt;
      &lt;td&gt;
          &lt;a href=&quot;{{ route('user.WalletTransaction', ['walletId'=&gt;$wallet-&gt;id,'userId'=&gt;$user-&gt;id]) }}&quot; class=&quot;fa fa-exchange text-dark mt-1&quot; /&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  @empty
      &lt;td colspan=&quot;5&quot; class=&quot;text-center&quot;&gt;No wallet exist&lt;/td&gt;
  @endforelse
  </code></pre>
  <p>It works fine, but the problem is, it shows two links in the table for one user. However, it should be showing one.</p>
  <p><a href="https://i.stack.imgur.com/pHTWK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pHTWK.png" alt="enter image description here" /></a></p>
  <p>And if I do:</p>
  <pre><code>@forelse($user-&gt;wallets as $wallet)
     {{ count(array($user)) }}
  @empty
      &lt;td colspan=&quot;5&quot; class=&quot;text-center&quot;&gt;
          No wallet exist
      &lt;/td&gt;
  @endforelse
  </code></pre>
  <p>The result would be <strong>1</strong>.</p>
  <p>The problem is coming from <code>'userId' =&gt; $user-&gt;id</code> of the link. Because if I remove it, only <strong>1</strong> link would appear, which is correct. But still, I do need the <code>userId</code> and don't know how to pass that into the route name.</p>
  <p>So what's going wrong here? I need one link for each user, and I don't know why it prints two of them.</p>