belongs to - Laravel Relationships -
i've been looking on relationships in laravel 4 in documentation , i'm trying work out following.
i have table in database called 'events'. table has various fields contain id's relate other tables. example, have 'courses' table. events table contains field called 'course_id' relates id of 'id' field in courses table.
so basically, i'm after advice on how go relating 2 (belongsto()?) , passing connected data view.
here @ far http://paste.laravel.com/pf3.
i hope guys able give me advice on how best approach problem. thanks.
gaz
this same answer @marko aleksić, hasone() , belongsto() relationships right way around.
class course extends eloquent{ protected $table = 'courses'; public function event() { return $this->hasone('event'); // links this->id events.course_id } } class event extends eloquent { protected $table = 'events'; public function course() { return $this->belongsto('course'); // links this->course_id courses.id } }