我遇到了尝试获取非对象的属性“位置”的错误。从简历提交页面重定向到另一页面时。
public function jobcode($job_code)
{
$jobpost = DB::table('jobposts')->where('job_code',$job_code)->first();
return view('home.resumesubmission',compact('jobpost'));
}
基本资格标准:{{$ jobpost-> position}}
<hr>
<p><strong>Job Code:</strong> {{ $jobpost->job_code }} </p>
<p><strong>Job Discription:</strong> {{ $jobpost->job_discription }} </p>
<p><strong>Skills Required:</strong> {{ $jobpost->skills_required }} </p>
<p><strong>Eligibility:</strong> {{ $jobpost->eligibility }} </p>
<p><strong>Package:</strong> {{ $jobpost->package }} </p>
<p><strong>Department:</strong> {{ $jobpost->department }} </p>
<p><strong>Location:</strong> {{ $jobpost->location }} </p>
<p><strong>Employement Type:</strong> {{ $jobpost->employement_type }} </p>
<p><strong>Note:</strong> {{ $jobpost->detail }} </p>
<hr>
有人可以帮忙吗?
答案 0 :(得分:0)
$jobpost
中有什么?它是数组还是对象还是null。如果它是一个数组,请尝试转储$jobpost
,而不要使用[]而不是->
更改
{{ $jobpost->position }}
到
{{ $jobpost['position'] ?? 'NA' }}
还将您的代码包装在@isset($jobpost)
'您的代码'@endisset