I have an intermediary table 'tour_tourists_documents'(i've also createad a model for it):
tour_id | tourist_id | doc_1 | doc_2
doc_1 and doc_2 relate to 'id' in table "Documents".
I want to set a relationship which retrieves both doc_1 and doc_2 from Documents. Smth like:
Class Tour_Tourist_Documents {
public function documents () {
return $this->hasMany('App\Documents', 'id', 'doc_1' AND 'id', 'doc_2');
}
so I want this method to return a collection of document models corresponding to doc_1 and doc_2. and preserving their relationship to 'Tour_tourist_documents" model.
I've tried to do it like Collin James advised here: Laravel 5 hasMany relationship on two columns But it returns:
LogicException with message 'Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation'