定制 lukapeharda/multitenancy 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

lukapeharda/multitenancy

Composer 安装命令:

composer require lukapeharda/multitenancy

包简介

A single DB multitenancy package for Laravel based on subdomain routing.

README 文档

README

Introduction

MultiTenancy is a Laravel single DB multitenancy package based on subdomain routing.

Installation

Require this package, with Composer, in the root directory of your project.

composer require lukapeharda/multitenancy

Add the service provider to config/app.php in the providers array.

LukaPeharda\MultiTenancy\Providers\ContextServiceProvider::class,

Publish the config file and modify its params to fit your needs and installation.

php artisan vendor:publish --provider="LukaPeharda\MultiTenancy\Providers\ContextServiceProvider"

Usage

Add the LukaPeharda\MultiTenancy\Scopes\Contextable trait to your models that are "tenant" dependable. This trait will automatically load global scope which will filter all your queries by defined tenant key.

Beside adding trait to your models, your model DB schema needs to have the tenant key as its attribute (and most likely as its foreign key).

To disable tenant global scope use withoutGlobalScope builder method:

$model->withoutGlobalScope(\LukaPeharda\MultiTenancy\Scopes\TenantScope::class);

Fetching the current tenant (and all of its attributes) is available through helper function context.

// To fetch entire tenant object
$tenant = context();

// To fetch one of its attribute
$tenantId = context('id');

License

MultiTenancy is open-sourced software licensed under the MIT license

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固