title: How to get index of element in Laravel collection
body: <p>How to retrieve the index of an element in a collection ?
  My code : </p>
  
  <pre><code>$users = User::has('posts')-&gt;withCount('posts')-&gt;orderBy('posts_count')-&gt;take(50)-&gt;get();
  
  if($users-&gt;contains(Auth::id())){
      //get the index of auth user id
   }
  </code></pre>
  
  <p>Thank's for help            </p>