承接 henryavila/laravel-nova-multitenancy 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

henryavila/laravel-nova-multitenancy

Composer 安装命令:

composer require henryavila/laravel-nova-multitenancy

包简介

Integrate the multi tenancy single database in Laravel Nova.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Integrate the multitenancy single database in Laravel Nova.

This package is based on https://spatie.be/docs/laravel-multitenancy. So logic and config of spatie/laravel-multitenancy still aplies

Installation

You can install the package via composer:

composer require henryavila/laravel-nova-multitenancy

You can publish the config, view, migrations and translation with:

php artisan vendor:publish --provider="HenryAvila\LaravelNovaMultitenancy\LaravelNovaMultitenancyServiceProvider" 

The views file will be published, personalize it at your will. Don't forget to run npm run build

You can run the migration with (To create the Tenant table)

php artisan migrate

Edit the app\Http\Kernel.php file adding an entry in web group and creating the tenant group

protected $middlewareGroups = [
    // ...
    
    'web' => [
        // ...
        \HenryAvila\LaravelNovaMultitenancy\Http\Middleware\SetTenantMiddleware::class,
    ],
    
    // ...
    
    'tenant' => [
        \HenryAvila\LaravelNovaMultitenancy\Http\Middleware\NeedsTenant::class,
        \HenryAvila\LaravelNovaMultitenancy\Http\Middleware\EnsureValidTenantSession::class,
    ]
];

If you activated (User Impersonation)[https://nova.laravel.com/docs/4.0/customization/impersonation.html] on Laravel Nova, you must set up this event Listeners.

Edit the file App\Providers\EventServiceProvider and add:

 protected $listen = [
        \Laravel\Nova\Events\StartedImpersonating::class  => [
            \HenryAvila\LaravelNovaMultitenancy\Listeners\ClearTenantSessionListener::class,
        ],
        \Laravel\Nova\Events\StoppedImpersonating::class => [
            \HenryAvila\LaravelNovaMultitenancy\Listeners\ClearTenantSessionListener::class,
        ],
];

Make your User model extends \HenryAvila\LaravelNovaMultitenancy\Models\User

If you want to customize the Tenant model, change it in config file

Add the trait \HenryAvila\LaravelNovaMultitenancy\Traits\ModelWithTenant to all models that are tenant aware

Add to your database file a tenant_connection entry with the tenant db connection. See:

return [
    // database.php
    'tenant_connection' => env('DB_TENANT_CONNECTION', 'tenant'),

This is the relation between the connections and the database

Name Database
default Landlord database
tenant_connection Tenant database

PS.: Don't forget to create this connections in database.connections config file.

Usage

To protect a specific route, just add the 'tenant' middleware to route

// in a routes file

Route::middleware('tenant')->group(function() {
    // routes
});

If you receive an error: Route [login] not defined.. Remember to change the route from login to nova.login in your App\Http\Middleware\Authenticate file

protected function redirectTo($request)
{
    return $request->expectsJson() ? null : route('nova.login');
}

Another option to don't define the tenant to an route is set the following default data to route declaration

Route::get('/', [Controller::class, 'index'])
		->defaults(\HenryAvila\LaravelNovaMultitenancy\LaravelNovaMultitenancy::SKIP_ROUTE, true);

If the Tenant has domains relationship, allow to define the current tenant based on current domain. The domains relation model, must contain an fqdn attribute with the fqdn domain

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

henryavila/laravel-nova-multitenancy 适用场景与选型建议

henryavila/laravel-nova-multitenancy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 150 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「henryavila」 「laravel-nova-multitenancy」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 henryavila/laravel-nova-multitenancy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 henryavila/laravel-nova-multitenancy 我们能提供哪些服务?
定制开发 / 二次开发

基于 henryavila/laravel-nova-multitenancy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 150
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-08-18