title: Laravel + add element to cookie and do not include in query
body: <p>I'm trying to do the following:</p>
  
  <p><strong>At page load:</strong></p>
  
  <p>Select <strong>one</strong> random idea from database.</p>
  
  <p>My code:</p>
  
  <pre><code>public function index()
  {
      if(Cookie::get('ideas'))
      {
          $ideas = Cookie::get('ideas');
          $ideas = unserialize($ideas);
      }
      else
      {
          $ideas = array();
      }
  
      $random_idea = Idea::inRandomOrder()-&gt;first();
      $ideas[] = $random_idea-&gt;id;
  
      Cookie::queue('ideas', serialize($ideas));
  
      return view('app', compact('random_idea'));
  }
  </code></pre>
  
  <p>I'm checking if the cookie is already set, if set, add the random idea to the cookie. If not, create new array and add the id to the array.</p>
  
  <p><strong>When they click a button on page (through ajax call).</strong></p>
  
  <p>My code:</p>
  
  <pre><code>public function idea(Request $request)
  {
      $ideas = Cookie::get('ideas');
      $ideas = unserialize($ideas);
  
      $random_idea = Idea::inRandomOrder()-&gt;first();
      $ideas[] = $random_idea-&gt;id;
  
      Cookie::queue('ideas', serialize($ideas));
  
      return response()-&gt;json($random_idea);
  }
  </code></pre>
  
  <p>I have 2 problems:</p>
  
  <ul>
  <li>The cookie variable is an array with always one element (id isn't added to the array)</li>
  <li>How can I select one random element from database that's <strong>NOT</strong> in the array?</li>
  </ul>