【发布时间】:2018-09-29 05:35:09
【问题描述】:
我想将用户查看的 cmets、帖子和个人资料保存在可查看的表格中。帖子和 cmets 显示在类似于社交网络的流中。如何在后台将数据存储在可查看的表格中?
表:
viewables
user_id
viewable_id
viewable_type
例如,如果用户查看或看到流中的帖子,则数据库应存储 user_id 和 post_id。 cmets 和配置文件应该也可以。
编辑:
帖子在 forelse 循环中发布,而 cmets 在 foreach 中发布。
@forelse ($posts as $post)
@if ($post->type === 1)
{{$post->body}}
@foreach ($post->comments as $comment)
{!!$comment->body!!}
@endforeach
@elseif ($post->type === 2)
{{$post->image}}
@foreach ($post->comments as $comment)
{!!$comment->body!!}
@endforeach
@elseif ($post->type === 3)
show post with type 3
@elseif ($post->type === 4)
show post with type 4
@else
show remaining
@endforelse
【问题讨论】:
-
你的意思是查看?你有每个评论的链接吗?当用户点击查看视图/评论时可能会触发 ajax 事件
-
不,我没有额外的意见。例如,如果用户查看或看到流中的帖子,则数据库应存储 user_id 和 post_id。 cmets 和配置文件应该也可以。
-
所以您要保存阅读帖子的人的用户 ID?需要更多关于如何设置帖子视图的信息。
-
@JPark 我在帖子中添加了一个示例视图