romegadigital/multitenancy-nova-tool
最新稳定版本:4.0.0
Composer 安装命令:
composer require romegadigital/multitenancy-nova-tool
包简介
A Laravel Nova tool to manage multitenancy.
关键字:
README 文档
README
This package is meant to integrate with the Multitenancy Package to bring multitenancy functionality and management to Laravel's Nova.
This package automatically includes the Multitenancy Package as a dependency. Please read the documentation on how to integrate it with your existing app.
Installation
Install the package via Composer:
composer require romegadigital/multitenancy-nova-tool
Then follow the Installation instructions to set up the Multitenancy Package.
Next, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.
// in app/Providers/NovaServiceProvider.php public function tools() { return [ // ... new \RomegaDigital\MultitenancyNovaTool\MultitenancyNovaTool, ]; }
This package requires Super Administrator or access admin permissions. This can be added either through the included permission management tool under "Roles & Permissions" or through our assign super-admin command.
Hint If you already executed
multitenancy:install, a role with the nameSuper Administratorand a permissionaccess adminattached was already created. Therefore you only need to add the role to a user.php artisan multitenancy:super-admin admin@example.com
Usage
New menu items labeled "Multitenancy" and "Roles & Permissions" will appear in your Nova app after installing this package.
To see the Tenant relation in the user detail view, add a BelongsToMany field to your app/Nova/User resource:
// in app/Nova/User.php use Laravel\Nova\Fields\BelongsToMany; public function fields(Request $request) { return [ // ... BelongsToMany::make('Tenants', 'tenants', \RomegaDigital\MultitenancyNovaTool\Tenant::class), ]; }
On each Nova resource that is tenantable, a BelongsTo field is required in order to see the relation to the Tenant model:
use Laravel\Nova\Fields\BelongsTo; public function fields(Request $request) { return [ // ... BelongsTo::make('Tenants', 'tenant', \RomegaDigital\MultitenancyNovaTool\Tenant::class), ]; }
Define Inverse Relationships
In order to display all related data to the Tenant model, you need to first implement a Tenant model that extends the package's provided model.
// in app/Tenant.php namespace App\Models; use RomegaDigital\Multitenancy\Models\Tenant as TenantModel; class Tenant extends TenantModel { // ... define relationships public function products() { return $this->hasMany(\App\Product::class); } }
Next, update your config file to point to your new model.
// in config/multitenancy.php // ... 'tenant_model' => \App\Models\Tenant::class,
Then create a Tenant Nova resource that extends the package's resource.
// in app/Nova/Tenant.php namespace App\Nova; use Illuminate\Http\Request; use Laravel\Nova\Fields\HasMany; use RomegaDigital\MultitenancyNovaTool\Tenant as TenantResource; class Tenant extends TenantResource { public static $model = \App\Models\Tenant::class; /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return array_merge(parent::fields($request), [ // ... define relationships HasMany::make('Products'), ]); } }
Middleware
To scope Nova results to the Tenant being utilized, add the middleware to Nova:
// in config/nova.php // ... 'middleware' => [ // ... \RomegaDigital\Multitenancy\Middleware\TenantMiddleware::class, \Vyuldashev\NovaPermission\ForgetCachedPermissions::class, ],
Accessing Nova at the admin subdomain will remove scopes and display all results. Only users given the correct permissions, such as Super Administrator, will be able to access this subdomain.
Policies
By default, the Multitenancy resource will only be visible on the admin subdomain to users with appropriate access to this subdomain. You may override the policy to allow more access to the resource by defining a policy within your project. And then within your AuthServiceProvider, register the policy:
// in app/Providers/AuthServiceProvider.php // ... protected $policies = [ // ... \RomegaDigital\Multitenancy\Models\Tenant::class => \App\Policies\TenantPolicy::class, ];
You can override the Permission and Role model policies by setting the policy file up in you config/multitenancy.php file. Look for policies.role and policies.permission.
romegadigital/multitenancy-nova-tool 适用场景与选型建议
romegadigital/multitenancy-nova-tool 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.01k 次下载、GitHub Stars 达 67, 最近一次更新时间为 2019 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nova」 「laravel」 「multitenancy」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 romegadigital/multitenancy-nova-tool 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 romegadigital/multitenancy-nova-tool 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 romegadigital/multitenancy-nova-tool 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
User actions logger dependency for Laravel Enso
A Laravel Nova Image field. you can paste or drag or chose an image
统计信息
- 总下载量: 9.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 67
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-22

