larabeans / tenanter
Apiato容器,用于添加多租户功能
dev-develop
2023-09-09 05:43 UTC
Requires
This package is auto-updated.
Last update: 2024-09-09 07:39:35 UTC
README
Larabeans > Tenanter
Tenanter
Apiato容器,用于添加多租户功能
概述
- 添加管理多租户功能,创建/添加/编辑
- 添加激活/停用租户账户的功能。
- 更新现有数据库结构,使其与多租户应用程序兼容
迁移
包括迁移,在所有现有数据库表中添加tenant_id
列。
种子
对于种子命名,使用后缀从_1到_10
包括以下种子的实现
- 租户角色
- 租户权限
- root管理员
- 租户管理员
- 默认root管理员
- 默认租户管理员
- 默认租户
用法
-
在core/beanner的User、Roles、ParentModel中使用HasTenancy特性(或根据您的模型相应地使用)
-
在core/beanner的User models上使用Authentication Trait(或根据您的模型相应地使用)
-
在User容器中,我们需要修改两个请求,如下所示
- \app\Containers\AppSection\User\UI\API\Requests\RegisterUserRequest.php
- \app\Containers\AppSection\User\UI\API\Requests\CreateAdminRequest.php
'email' => 'required|email|max:40|unique:users,email,NULL,id,tenant_id,' . tenant()->getTenantKey(),
-
在AppSection/Authorization/UI/API/Requests/CreateRoleRequest.php中更新角色名称验证规则如下
'name' => 'required|unique:' . config('permission.table_names.roles') . ',name,NULL,id,tenant_id,' . tenant()->getTenantKey() . '|min:2|max:20|no_spaces',
待办事项
- 实现CLI(artisan)命令,将租户列添加到任何表(指定表名和列类型,例如increment或uuid)
- 实现CLI(artisan)命令,在数据库中添加默认租户
- 删除CLI命令Add TennatIdToTablesCommand
- 从配置器容器中删除CLI命令以添加主机配置(它已在此处处理)
- 从tenanter配置中删除host_domains的使用