正如標題中提到的,我得到錯誤"Property [id] does not exist on this collection instance."
只有當我在線運行代碼時,這裏是我的相關代碼。Laravel錯誤:此集合實例上不存在屬性[id]。但它在本地服務器上工作
1 EmployeeController(瀏覽器告訴我的錯誤是這裏的第二行)
public function show(Employee $employee)
{
$employee = Employee::find ($employee);
$edocument = EDocument::where ('employee_id',$employee->id)->first();
return view ('employee.show')->withEmployee($employee)->withEdocument($edocument);
}
2 show.blade.php
<div class="jumbotron">
<h1>{{$employee->name}} ({{$employee->position}})</h1>
@if (isset($edocument))
<a href="{{route('employee-docs.show',$edocument->id)}}" class="btn btn-lg btn-primary">Go To Employee Database Page</a>
@else
<p class="lead bg-danger">Employee documents are not uploaded</p>
@endif
<a href="{{route('getContract',$employee->id)}}" class="btn btn-success btn-lg">Create Employee Contract </a>
如果任何人都可以解釋我更詳細的這個錯誤,這將是偉大的。感謝
PS ..這是我的第一個項目laravel(;
謝謝。是的,我做到了這一點,它的工作......我想我沒有注意到這個錯誤,因爲代碼在某種程度上在本地工作,這很奇怪。 –