laravel 5 - ErrorException Invalid argument supplied for foreach() when trying to access a static class function -


errorexception invalid argument supplied foreach(),here trying. can working when call sort methods in controller rather caliing sortitems method.

errorexception invalid argument supplied foreach()

// controller $items = item::sortitems($orderby);  // model  static function sortitems($orderby) {     if($orderby == 'popular'){          db::table('items')->orderby('views','desc')->paginate(50);      }     elseif ($orderby == 'lowest-price'){          db::table('items')->orderby('price','asc')->paginate(50);      }      elseif ($orderby == 'highest-price'){          db::table('items')->orderby('price','desc')->paginate(50);      }      else{         db::table('items')->orderby('id','desc')->paginate(50);      } }   // view     @foreach($items $row)      {{ $row->id }}   @endforeach 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -