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     }  } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -