dongxiongshi9952 2016-07-07 20:13
浏览 10
已采纳

Laravel 5.2中的组成? 可能? 推荐的?

I'm about to start a Laravel project and I have doubts about how I should go about it. First of all, I'll have two types of users, the common user, and the admin. I have searched a bit and found out that having two tables is the best solution in my case. Because common users will have all the columns the admins have plus a few more.

I'll create a users_table and a common_users_table. The admins will have their data on the users_table and the common users will have their data spread across both of the tables, with a foreign key on the common_users_table referencing the users_table. This way no columns will be unused.

My problem is, I'm not sure how to accomplish that in Laravel. Should I create only 1 model? Maybe 2 models with a hasOne and belongsTo relationship? But when I make the registration forms, how will I register 2 models at once? What about authentication? There are so many things that I simply don't have the experience in Laravel to determine what is better in the long run.

So, if you are more experienced in Laravel and/or have faced a problem like this before, what is the best way to tackle this problem?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • duanlangwen9597 2016-07-07 20:22
    关注

    Look into something like laravel's ACL and the Guards, as this would be a good thing to do: ACL in Laravel, so this would give you users and permissions,

    There are also some nice little packages you could leverage.

    Sorry, the link above you might need a subscription to watch, but the terms might be a good starter as well as the site for also help on the ACL stuff

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?