laravel - 想要显示添加评论的用户名
问题描述
我是 Laravel 的新手,在我的项目中,我想在身份验证后在博客中添加评论,我对此使用会话,所以问题是他不显示用户名!
这是我的控制器评论:
public function store (blog $getid , Request $request)
{
$patient_id=$request->session()->get('patient_id');
comment::create([
'body' =>request('body'),
'blog_id'=> $getid->id,
'patient_id'=>$patient_id
]);
return back();
}
这是 show.blade.php :
@foreach ($showme->comments as $comment)
<blockquote class="blockquote mb-0">
<p style="font-size:15px;">{{$comment->body}}</p>
<p> {{$comment->patient_id}}</p>
<footer class="blockquote-footer"> {{$comment->created_at}} <cite title="Source Title"> </cite></footer>
</blockquote>
@endforeach
</div>
<!-- si le patient est connceter -->
@if(Session::has('log_in'))
<div class="card-block">
<form method="POST" action="/blog/{{$showme->id}}/store" >
@csrf
<div class="form-group">
<label> Commentaire </label> </br>
<textarea name="body" rows="3" cols="80" cols="form-control"></textarea> </br>
</div><div class="form-group">
<button type="submit" class="btn btn-primary"> Ajouter commentaire</button>
</div>
</form>
</div>
@endif
WEB.PHP
Route::Post('/store' , 'patientcontroller@store');
太感谢了
解决方案
推荐阅读
- reactjs - 如何将 useState 的状态设置为输入按钮值,因此每当值更改时,状态也会更改?
- javascript - 如何在nodejs中导入
- javascript - 如何将 base64 编码的字符串转换为 ReadableStream?
- c# - 将 Int* 和 double* 从 C++ 传递到 C#
- angular - Azure 应用服务部署的应用未更改请求 URL
- javascript - 如何将推特链接转换为嵌入式推文?
- wso2 - WSO2 API 管理器未将更改应用到存储库/组件/lib 中的外部 jar 文件
- json - 如何从 Python 中的多行字符串变量中提取 JSON
- r - 如何绘制带有闪避点或饼图点的 ggplot2 散点图?
- javascript - 我为桌面上的 Chrome 编写的 Javascript BLE 应用程序是否也可以在 Android 上的 Chrome 上运行?