Search code examples
databaselaraveldata-structurespackageaccess-rights

best way to implement laravel database system to manage posts read/share/edit permissions


Thank you for helping on this! I am designing an app with documents and posts sharing with Laravel. I tried to do it myself since two weeks but I am not sure what the best is. I've tried implementing many packages and used crud generators, but as a Laravel beginner it's difficult to find the good package and to mix them. What I want is a system like google docs sharing behaviour but for posts. You could write a post and set it as

  • private
  • shared with those with the secret link
  • shared with users names list (or ids in database)
  • shared with groups of users

So what is the best way to build that?

  • 1) Using a package? Which one?
  • 2) table_users | table_posts | table_permissions
    • one permission per user that can read / edit (permission level)
  • 3) table_users | table_posts including permissions for each posts
    • owner_id
    • share_link
    • users_that_can_read
    • users_that_can_edit

If anyone can direct me to a good tutorial or give me a good start structure for this tables to be efficient and secure.

Maybe I do not see all the complexity of this so I will enjoy any suggestions The problem for this is I want a more flexible rights management than wordpress one that provides user rights levels, the availability of data will be managed by simple subscribers for a lot of things(files, posts, maybe comments, groups and maybe more stuff).


Solution

  • You just need to create three tables roles,permissions and roles_permission.The roles of the user goes in the table roles table.the permission of a user are stored in the table permission.You can map the roles and permission of a particular user in the roles_permission table.However,for more flexible way to add role-based-permission use entrust package.In which,you can dynamically add/update/delete the roles and permissions in laravel.