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

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

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 flask项目,怎么使用AJAX传数据库数据到echarts图表的data里,实现异步加载数据。
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题