title: Laravel 5: Undefined variable return_array
body: <p>I'm trying to get data with ajax call, and after sending the ajax call i want to store data in array, but I'm getting this error when I open the page.</p>
  
  <pre><code>Undefined variable: return_array
  </code></pre>
  
  <p>My function </p>
  
  <pre><code>public function findUser(Request $request) {
      $findUserInput = $request-&gt;get('name');
      $user = DB::table('users')
          -&gt;where('name', $findUserInput)
          -&gt;first();
  
      $data =  DB::select("SELECT * FROM users WHERE name='$user'");
  
      foreach ($data as $da) {
          $return_array[] = $da;
      } 
  
      return $return_array;      
  }
  </code></pre>
  
  <p>Any ideas?</p>