I have 3 tables (also 3 models), User, Company and UserCompany, (images here: http://prntscr.com/dguedl), I have a page where I get all companies from a user this is table UserCompany, there I get company id, how can I create now relation (which type) to get company name?
@mstnorris I have a page if user is logged in then he become assigned companies listed, in the table UserCompany are companies assigned to user, user can has more companies.
I list here assigned companies id's, there are in UserCompany, but I want to use Model Company to get company name. How can I use it in blade?
I list assigned companies with help from following relation:
public function userCompanies() {
return $this->hasMany('App\Models\UserCompany');
}
And this is blade file:
@foreach($userCompanies as $userCompany)
<li><a href="">{{ $userCompany->company_id }}</a></li>
@endforeach