2 years ago

Add default value to pivot table (users_role) when creating a new user

Posted 2 years ago by Edelco


Been searching the internet to get an answer to my problem.

I created a Roles/Permissions ability in my Laravel project by taking a videocourse. It uses pivot tables. My database contains the following standard Laravel tables after php artisan make:auth (and migrate):

  • users
  • password_resets

For the roles/permissions ability I created the following tables:

  • roles (id, name)
  • permissions (id, name)
  • roles_permissions (role_id, permission_id)
  • users_roles (user_id, role_id)
  • users_permissions (user_id, permission_id)

I also created a Trait:

Please sign in or create an account to participate in this conversation.