I'm using the eloquent ORM in Laravel with a hasMany
relationship.
when I run:
Level::find(1)->lessons()->get();
It works fine, but when I use the dynamic property like so:
Level::find(1)->lessons
It just returns results for the level
instead of the lessons
.
Do I need another setting somewhere?
EDIT: Here are the models:
class Level extends Eloquent {
protected $table = 'levels';
public function lessons()
{
return $this->hasMany('Lesson');
}
}
class Lesson extends Eloquent {
protected $table = 'lessons';
public function level()
{
return $this->belongsTo('Level');
}
}