Actually, my question is very simple but I couldn't find any answer.
I'm using Laravel eloquent, I have 3 tables:
company_types
-id
-name
document_types
-id
-name
and a pivot table called:
company_type_document_type
-company_type_id
-document_type_id
-is_default
I already have the company_type_id
from my company object and I'm trying to get the name
of the document_type
like this:
controller...
$document_type = CompanyTypesDocumentTypes::where('company_type_id',$company->company_type_id)->with('document_type')->where('is_default',true)->first();
view...
{{ $document_type->name }}
I'm sure that the problem is with my models, but the issue is that I don't really understand when to user "hasMany" or "BelongsToMany" etc... In Addition, I think that there might be a problem with the name of the pivot table cause there are too many underscores
thank you for your help!