Created
November 17, 2014 14:02
-
-
Save sleeping-owl/2e1d1cef3d820e440b51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Product extends \Eloquent | |
{ | |
public function category() | |
{ | |
return $this->belongsTo('Category'); | |
} | |
public function options() | |
{ | |
return $this->belongsToMany('ProductOption'); | |
} | |
} | |
class ProductOption extends \Eloquent | |
{ | |
public function products() | |
{ | |
return $this->belongsToMany('Product'); | |
} | |
} | |
class Category extends \Eloquent | |
{ | |
public function products() | |
{ | |
return $this->hasMany('Product'); | |
} | |
} | |
$products = Product::with('category', 'options')->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment