【发布时间】:2020-07-19 13:12:15
【问题描述】:
我有一个问题,我不知道如何解决它,我有一个页面显示了一些问题,从数据库中获取,我做了一个 cmets 部分,我如何根据 post_id 获取 cmets?我试着把它们拿走,但它没有显示出来,我做了类似的事情:
路线::
Route::get('/viewUserQuestion/{post}', 'PostsController@viewUserQuestion')->name('viewQuestion');
控制器:
public function viewUserQuestion(Post $post, Comment $comment) { return view('viewQuestion', compact('post'), compact('comment'));
只有当我有类似comment [0] -> commentText 时才会显示给我,如果我没有收到错误,建议我如何根据 id 获取它们?
架构::
$table->id();
$table->integer('post_id')->default();
$table->integer('user_id');
$table->text('commentText');
$table->timestamps();
});```
...
【问题讨论】: