dsq30861 2019-01-31 11:06
浏览 75

访客和用户Laravel的注释表结构

I want release comments system for guest and site users. I need, when guest add comment, I need check email him. For it, when guest add comment, he can write "name", "email", "body" of comment. When he send comment, I need confirm email him, for it in table I have column email_token.

Now My comments table structure:

- id
- post_id
- user_id
- name
- email
- email_token
- email_verified_at
- body
- created_at
- updated_at

I have a question about structure of my table. How will be better? Do all columns for guest (name, email, email_token, email_verified_at) in comments table, or create separate table for guest comments? I need show all active comments in post model. If guest not confirmed email, then comment not active.

In post model I have this:

public function comments() {
    return $this->hasMany('App\Comment')->whereNotNull('email_verified_at')->orWhereNotNull('user_id'); //display only comments by user and guest (with confirmed email)
}
  • 写回答

2条回答 默认 最新

  • dtoqa66028 2019-01-31 11:12
    关注

    I suggest to have a separate table or you can use a users table which you may have used for registered user that way you can remove duplicate data.

    In future, the guest user might become a site user as well. So better, you add one flag called "is_guest" or "type" in your user table.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法