php - Laravel one-to-many relationship with pivot table -
i have 3 tables in database. link table, question table , answer table. in link store evaluationmoments. in question store questions can asked in evaluations. in answer store answers user has given in evaluation. want answers given specific evaluation.
link has primary key link_id. question has primary key question_id. answer has primary key anwer_id.
link , question connected many-to-many relationship. therefore there pivot table called link_question. keys link_id , question_id.
in laravel models have these functions:
class link extends ardent{ public function question(){ return $this->belongstomany('question'); } class question extends ardent{ public function link(){ return $this->belongstomany('link'); }
this works fine. however, want give answer table many-to-one relation pivot table. every entry in pivot table there multiple answers. how got implementing in laravel? don't have model pivot table can't add function there.
Comments
Post a Comment