title: laravel 5.4 convert collection of eloquent object to integer
body: <p>When i try to compare collection of object with an integer..here  </p>
  
  <pre><code>@if($in_closet == $product-&gt;id )
                  &lt;li&gt;&lt;a id="add_closet" href="{{ route('user.addtocloset', ['id' =&gt; $product-&gt;id]) }}"&gt;&lt;i class="fa fa-archive" aria-hidden="true"&gt;&lt;/i&gt; Add to closet&lt;/a&gt;&lt;/li&gt;
                  @else
                  &lt;li&gt;&lt;a id="my_closet" href="{{ route('closet') }}"&gt;&lt;i class="fa fa-archive" aria-hidden="true"&gt;&lt;/i&gt; My Closet&lt;/a&gt;&lt;/li&gt;
                  @endif
  </code></pre>
  
  <p>In <code>$in_closet</code> variable i am having collection of object like this [50,52,53,54] when i try to compare with <code>$product-&gt;id</code> having value as integer it show me this error </p>
  
  <blockquote>
    <p>Object of class Illuminate\Support\Collection could not be converted
    to int</p>
  </blockquote>
  
  <p>This is in my controller variable</p>
  
  <pre><code>   $in_closet = ProductCloset::where('closet_id',$user-&gt;id)-&gt;pluck('product_id');
  </code></pre>
  
  <p>I now find the problem but how my question is how to resolve it what i exactly need is if the product id equals to  any product id in that collection object show one div else show another div..</p>
  
  <p>I want to know how to compare collection object to integer or how did i achieve this ..please any one help to find solution to this problem</p>