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 微带串馈天线阵列每个阵元宽度计算
  • ¥15 关于无人驾驶的航向角
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了