Answer the question
In order to leave comments, you need to log in
How to select models from multiple tables?
Docks about communications read, but it is not clear.
There is an entity/table Document.
There is an entity/table DocumentType - in fact, this is just a reference.
Document has a foreign key on the table DocumentType
I tried to make a select:
return $this->model
->with('document_types')
->orderBy($orderBy, $sort)
->paginate($paged);
public function document_types()
{
return $this->hasOne(DocumentType::class, 'type_id', 'id');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question