i am new to Laravel model relationships, and i am trying to learn it by building a basic forum system. I am trying to have the fourms belong to the forums categories:
Here is my ForumCategory model:
class ForumCategory extends Eloquent {
protected $table = 'forum_categories';
public function forums()
{
return $this->hasMany('Forum','category_id');
}
}
The forum model name is Forum and the foreign key is category_id.
Here is the forum model:
class Forum extends Eloquent {
protected $table = 'forums';
}
Here is how I try to test it:
$category=ForumCategory::find(1);
print_r($category->forums());
But what i get from the print_r is a very large object, and not the related forums.
Thank you.