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 關注
- 117 瀏覽
添加回答
舉報