larawire-garage/simple-multitenancy
最新稳定版本:v1.0.0
Composer 安装命令:
composer require larawire-garage/simple-multitenancy
包简介
Support user multitenancy for laravel application
README 文档
README
Support Multitenancy for laravel application
Installation
composer require larawire-garage/simple-multitenancy
publish configurations
php artisan vendor:publish --tag=simple-mutitenancy-configs
Usage
call userBy() at the end of the Schema create callback function in the migration file
Schema::create('users', function (Blueprint $table) {
// other columns
$table->userBy();
});
The userBy(bool $hasSoftDeletes = true) function will add following columns to the table
- created_by
- updated_by
- deleted_by [only $hasSoftDeletes == true]
Inside the Model
use HasUserBy trait in the model which needed multitenancy
// app/Models/User.php
class User extends Authenticatable {
use HasUserBy;
}
// app/Models/Post.php
class Post extends Model {
use HasUserBy;
}
Retrieve User
$post->createdBy(); // return App\Models\User|null
$post->updatedBy(); // return App\Models\User|null
$post->deletedBy(); // return App\Models\User|null
!!! 🎉🎉🎉 Enjoy 🎉🎉🎉 !!!
统计信息
- 总下载量: 359
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-19