1 回答

TA贡献1810条经验 获得超4个赞
当您迭代时,$user->posts它会起作用,因为您正在访问每个帖子并渲染它。
但在您posts.edit使用时$user->posts->about,它不知道哪篇文章是关于哪篇文章的。
解决方案: 您必须像您提供的工作代码一样迭代该用户的所有帖子。
.....
@foreach($user->posts as $post)
<label for="about" class="col-md-4 col-form-label text-md-right">{{ __(' post about') }}</label>
<div class="col-md-6">
<input id="about" type="text" class="form-control @error('about') is-invalid
@enderror" name="about" value="{{ old('about') ?? $post->about }}"
required autocomplete="about" autofocus>
@error('about')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
@endforeach
....
- 1 回答
- 0 关注
- 94 浏览
添加回答
举报