i have subject table contains
id name
and languages table contains
id subject_id
and division table
id name
finally subject-division table (pivot table)
id subject_id division_id
now exist one-to-one relationship between subject table , languages table , many-to-many relationship between subject table , division table, need pluck subjects of subject table without languages using relationship function
now can languages of subject table of relationship function in division model following
public function langsubject () { return $this->belongstomany('subject' , 'subject_division','division_id','subject_id') ->join('lang_subject', 'lang_subject.subject_id' ,'=', 'subject.id')->get(); }
but till can't subjects without languages
any suggestions ?
you need add clause ->select('tablename1.fieldname1','tablename2.fieldname2','tablename3.fieldname3') statement after join statement tablename.fieldname , may need use leftjoin instead of join results whether if there match or not.