定制 pandorga/owner 二次开发

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

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

pandorga/owner

Composer 安装命令:

composer require pandorga/owner

包简介

Allow Eloquent models to own each other. Supports many to many relationships.

README 文档

README

A simple package that allows Eloquent models to "own" each other, or "be owned" by another model. Supports many-to-many relationships.

Examples could include:

  1. A user owning a blog post.
  2. A user and a team owning multiple files.
  3. Record being owned by many organizations.

Installation

Requirements

  • Composer
  • Laravel Framework 5.7+/6.0+/7.0+

Installing

Run the following command in your console terminal:

$ composer require pandorga/owner

Publish the migrations and config files:

$ php artisan vendor:publish --provider="Pandorga\Owner\OwnerServiceProvider"

Run the migrations:

$ php artisan migrate

Usage

Add necessary traits your Eloquent models:

If the model can be an owner:

use Pandorga\Owner\Traits\Owns;
    
class User extends Model
{
    use Owns;
}

If the model can be owned by another model:

use Pandorga\Owner\Traits\HasOwner;
    
class Resource extends Model
{
    use HasOwner;
}

Usage

"Owner" model:

Create an ownership:

$user->own($model);

Remove an ownership:

$user->disown($model);

Return a collection of all the models owned by the parent model:

$user->owns();

Does the user own this model?

$user->ownsModel($model);

Which models of this type does the parent model own? This method either takes a child model, or a name-spaced class name.

$user->ownsModelType($model); // Use a model
$user->ownsModelType(‘App\Resource’); // Use class name

"Owned" model:

Return a collection of all the model's owners:

$model->owners();

Is the model is owned by another model?

$model->isOwnedBy($owner);

Add an owner to the model:

$model->addOwner($owner);

Remove an owner from the model

$model->removeOwner($owner);

Remove all owners from the model

$model->removeAllOwners();

Security

If you discover any security related issues, please use the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固