title: Laravel has_many. Am I doing this correctly?
body: <p>I'm new to Laravel (and OOP) and I'm putting together a store. I have put together a relationship for my product images, it works as I need it to but I just wanted to check that I'm doing it correctly/efficiently. If anyone experienced with Laravel could cast their eye over the below and suggest improvements or give me some feedback, it would be greatly appreciated.</p>
  
  <p>I have products which have many product images. Here are my models for product and productimage:</p>
  
  <p>Product:</p>
  
  <pre><code>class Products extends Eloquent {
  
      public static $table = 'core_Products';
      ........
      public function ProductImages(){
          return $this-&gt;has_many('ProductImage', 'product_id');
      }
  }
  </code></pre>
  
  <p>Productimage:</p>
  
  <pre><code>class ProductImage extends Eloquent{
  
      public static $table = 'core_productimages';
  
      public function product(){
          return $this-&gt;belongs_to('Product');
      }
  }
  </code></pre>
  
  <p>My product controller (this is where I am thinking I could be doing things more efficiently. Surely I shouldn't need to be passing the product_id to retrieve the images. Shouldn't the model already be aware of this?):</p>
  
  <pre><code>class Store_Product_Controller extends Base_Controller {
  
  public function action_index($serfURL = "", $intSectionID, $pSerfURL = "", $intProductID)
  {
  
              .......
      $view-&gt;productImages = Products::find($intProductID)-&gt;ProductImages()-&gt;get();
  
      return $view;       
  
  
      }
  
  }
  </code></pre>
  
  <p>and finally, my view:</p>
  
  <pre><code>foreach ($productImages as $image){
      echo $image-&gt;strImageURI . "&lt;br/&gt;";
  }
  </code></pre>