title: Adding custom methods to Eloquent Model in Laravel
body: <p>I have an Eloquent Article model in my Laravel 4 app. It's empty at the moment, but what I want to do is define two methods:</p>
  
  <ul>
  <li>getNextArticle</li>
  <li>getPreviousArticle</li>
  </ul>
  
  <p>So that when I use:</p>
  
  <pre><code>$article = Article::find(1);
  </code></pre>
  
  <p>I can follow up with:</p>
  
  <pre><code>$article-&gt;getNextArticle;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$article-&gt;getPreviousArticle;
  </code></pre>
  
  <p>I need to get access to the results returned from find() within the Articles model so I can use the data to get the next and previous articles from an SQL query.</p>
  
  <p>Theoretically I end up with something like:</p>
  
  <pre><code>class Article extends Eloquent
  {
      public function getNextArticle()
      {
          // SQL query to get next article from the database
      }
  
      public function getPreviousArticle()
      {
          // SQL query to get previous article from the database
      }
  }
  </code></pre>