title: Laravel correct php code doesnt work in class's function
body: <p>this below code work fine without any problem, but after move that into function i get error and doesnt work</p>
  
  <pre><code>Route::get('test', ['as' =&gt; 'test', function () {
      $data = 'MYURL';
  
      $table = [];
  
      $html = new \Htmldom($data);
      foreach($html-&gt;find('tr') as $row) {
          $col_1 = $row-&gt;find('td',0)-&gt;plaintext;
          $col_2 = "";
          try{
              $col_2= $row-&gt;find('td',1)-&gt;plaintext;
          }catch (Exception $ignore){}
  
          $table[] = $col_2;
      }
  
      $values = array_values($table);
      unset($values[0]);
      unset($values[1]);
      unset($values[5]);
      $values = array_values($values);
      print_r($values);
      /*print_r(\App\Customs\Helpers::get_online_currencies());*/
  }]);
  </code></pre>
  
  <p>My Class:</p>
  
  <pre><code>class Helpers
  {
      public static function get_online_currencies(){
          $data = 'MYURL';
  
          $table = [];
          $html = new \Htmldom($data);
  
          foreach($html-&gt;find('tr') as $row) {
              $col_2 = "";
              try{
                  $col_2= $row-&gt;find('td',1)-&gt;plaintext;
              }catch (Exception $ignore){}
  
              $table[] = $col_2;
          }
  
          $values = array_values($table);
          unset($values[0]);
          unset($values[1]);
          unset($values[5]);
  
          return array_values($values);
      }
  }
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>ErrorException in Helpers.php line 23: 
  Trying to get property of non-object
  </code></pre>
  
  <p><strong>line 23:</strong></p>
  
  <pre><code>$col_2= $row-&gt;find('td',1)-&gt;plaintext;
  </code></pre>
  
  <p>You can test my code.</p>