title: Is it bad practice for a model to call itself within itself?
body: <p>Here's an example, using Eloquent in Laravel.</p>
  
  <p>Let's say I'm working on a CMS.</p>
  
  <ul>
  <li>the controller takes the route and looks up the page via the route.</li>
  <li>the model provides a static function that uses the route to figure out the id of the row it's looking for</li>
  <li>the model then <strong>uses itself</strong> to perform the database query and returns the result</li>
  </ul>
  
  <p><strong>Example Controller Code:</strong></p>
  
  <pre><code>Route::get('(.*)', function($route)
  {
      $page = Page::load_by_route($route);
  });
  </code></pre>
  
  <p><strong>Example Model Code:</strong></p>
  
  <pre><code>class Page extends Eloquent {
  
      public static function load_by_route($route)
      {
          // Explode the route and trace to find the actual id of the row we need.
          // ... some lines of code to accomplish it...
  
          // Use the $id we discovered to perform the actual query
          $page = Page::find($id)-&gt;first();
  
          return $page;
      }
  }
  </code></pre>
  
  <p>Before you ask "Why can't you just use <em>Page::where('route', '=', $route)->first()</em> in the first place: I'm not wondering 'how to do' this example. I'm just wondering if it is it bad to to be using Page:: inside the page model?</p>