我使用 laraver 生成器(infyom)。在“公司”表中有合作伙伴ID,但没有合作伙伴的名称。我想要显示另一个名为partners的表中的合作伙伴名称。我怎样才能做到这一点?
公司(table.blade.php)
<div class="table-responsive">
<table class="table" id="companies-table">
<thead>
<tr>
<th>Name</th>
<th>Partner ID</th>
<th>Type</th>
<th>Nip</th>
<th>Street</th>
<th>Building Num</th>
<th>Apartment Num</th>
<th>Postal Code</th>
<th>Place</th>
<th>Floor</th>
<th colspan="3">Action</th>
</tr>
</thead>
<tbody>
@foreach($companies as $company)
<tr>
<td>{{ $company->name }}</td>
<td>{{ $company->partner_id }}</td>
<td>{{ $company->type }}</td>
<td>{{ $company->NIP }}</td>
<td>{{ $company->street }}</td>
<td>{{ $company->building_num }}</td>
<td>{{ $company->apartment_num }}</td>
<td>{{ $company->postal_code }}</td>
<td>{{ $company->place }}</td>
<td>{{ $company->floor }}</td>
<td>
{!! Form::open(['route' => ['companies.destroy', $company->id], 'method' => 'delete']) !!}
<div class='btn-group'>
<a href="{{ route('companies.show', [$company->id]) }}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
<a href="{{ route('companies.edit', [$company->id]) }}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
</div>
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>