laravel - 如何获取文章所有者 user_id 并保存到 notifiable_id 字段
问题描述
如何获取文章所有者 user_id 并保存到 notifiable_id 字段假设 $articlecomment = $article_owner_id
我的代码:
$articlecomment = new Article_comment();
$articlecomment->user_id = Auth::user()->id;//Comment by user id
$articlecomment->article_id = $request->articleid;
$articlecomment->comment = $request->comment;
$articlecomment->save();
auth()->user()->notify(new ArticleNotification($articlecomment));
//$articlecomment->user()->notify(new ArticleNotification($articlecomment));
数据库屏幕截图我想要 notifible_id 字段上的 article_owner_user_id 在此处 输入图像描述
解决方案
Solved
$articlecomment->save();
$article = Article::where('id','=',$request->articleid)->first();
if($article->user_id != Auth::User()->id){
$article->user->notify(new ArticleNotification($article));
}
推荐阅读
- php - 使用 glob(..., GLOB_BRACE) 按文件名排序
- java - 编译时出错:用于编码 windows-1252 的不可映射字符 (0x90D)
- javascript - 如何等到循环内的语音完成?
- sql - 使用自定义逻辑处理来自 Redshift 的数十亿条记录
- postgresql - 得到错误 r:在“$total$ 声明总整数”处或附近未终止的美元引号字符串;
- html - 如何在闪亮的html中从ggplot中删除底部边框?
- python - 如何在 Python 中运行如下并行任务?
- javascript - 如何循环浏览 Firebase 中的快照
- javafx - 无法以编程方式选择使用对象的 Javafx 组合框项目
- c# - 我可以在 HttpSys 管道中找到控制器吗?