我是 Laravel 的新手。我有一个页面,其中显示了所有已申请工作的候选人。
工作申请.blade.php
<table class="table table-hover table-striped" id="dataTable" style="font-size: 13px !important">
<thead>
<th style="padding:5px 22px 10px 6px !important">Candidate</th>
<th style="padding:5px 22px 10px 6px !important">Status</th>
<th style="padding:5px 22px 10px 6px !important">Edit</th>
</thead>
<tbody>
@foreach ($applications as $application)
<tr>
<td>
<a class="text-center" href="{{ route('candidates.show', $application->user->username) }}"
target="_blank" class="text-theme">{{ $application->user->name }}</a>
</td>
<td>
{{ $application->status }}
</td>
<td>
<a href="route('employers.applicants.edit', $applicant->id)" class="mt-1 text-center btn-sm btn btn-outline-yellow"> <i class="fa fa-pencil"></i> Edit</a>
</td>
</tr>
</tbody>
</table>
每当我单击编辑按钮时,它都会显示错误
尝试获取非对象的属性“id”
这是我的 jobApplications 控制器代码
public function jobApplications($slug)
{
if (!Auth::check()) {
session()->flash('error', 'Sorry !! You are not an authenticated Employer !!');
return back();
}
$user = Auth::user();
$user_id = $user->id;
$applicant = DB::table('job_activities')->where('user_id',$user_id)->get();
$job = Job::where('slug', $slug)->first();
$expreience_data = Experience::all();
$query = JobActivity::query();
$applications = $query->where('job_id', $job->id)->get();
$experiences = [];
$education = [];
$application_data = [];
它在线上给出错误:
$applications = $query->where('job_id', $job->id)->get();
根据我可以通过互联网找到的解决方案,这是因为我试图将对象类型 ID 分配给数组应用程序。我尝试将 $jobs 变量上的 first() 更改为 get() 但随后出现错误
此集合实例上不存在属性 [id]。
慕村225694
富国沪深