尝试获取非对象的属性"名称"(查看:C:\xampp\htdocs\joblister-laravel-8-main\resources\views\job-app



我在一个工作门户网站上工作,当我想向公司显示求职者时,我遇到了以下错误。我不知道错误在哪里,请帮帮我!

Laravel正在展示:这是错误屏幕截图

我的index.blade.php的代码是:

@extends('layouts.account')
@section('content')
<div class="account-layout  border">
<div class="account-hdr bg-primary text-white border">
Job Applications
</div>
<div class="account-bdy p-3">
<div class="row">
<div class="col-sm-12 col-md-12">
<p class="mb-3 alert alert-primary">Listing all the Applicants who applied for your <strong>job listings</strong>.</p>
<div class="table-responsive pt-3">
<table class="table table-hover table-striped small">
<thead>
<tr>
<th>#</th>
<th>Applicant Name</th>
<th>Email</th>
<th>Job Title</th>
<th>Applied on</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@if($applications->count())
@foreach($applications as $application)
<tr>
<td>1</td>
<td>{{$application->user->name}}</td>
<td><a href="mailto:{{$application->user->email}}">{{$application->user->email}}</a></td>
<td><a href="{{route('post.show',['job'=>$application->post->id])}}">{{substr($application->post->job_title,0,14)}}...</a></td>
<td>{{$application->created_at}}</td>
<td><a href="{{route('jobApplication.show',['id'=>$application])}}" class="btn primary-outline-btn">View</a>
<form action="{{route('jobApplication.destroy')}}" method="POST" class="d-inline-block">
@csrf
@method('delete')
<input type="hidden" name="application_id" value="{{$application->id}}">
<button type="submit" class="btn danger-btn">Delete</button>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td>You haven't received any job applications.</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
@endif
</tbody>
</table>
</div>
<div class="d-flex justify-content-center mt-4 custom-pagination">
{{ $applications && $applications->links() }}
</div>
</div>
</div>
</div>
</div>
@endSection

如果您正在使用Application和User表的联接关系,并且记录在$applications变量中,则它在错误中明确提到用户不存在。我们可以从这段代码中判断出哪里出了问题。你能给我们看一下传递$applications值的控制器吗?可能的解决方案可以是$application->用户['name'];

最新更新