inventive/laravel-owner 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

inventive/laravel-owner

Composer 安装命令:

composer require inventive/laravel-owner

包简介

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

README 文档

README

Laravel Owner

Laravel Owner

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 organisations

Installation

Install using composer:

composer require inventive/laravel-owner=dev-master

Add the following to config/app.php:

Inventive\LaravelOwner\OwnerServiceProvider::class,

Publish the migrations and config files:

php artisan vendor:publish

Run the migrations:

php artisan migrate

Add necessary traits your Eloquent models:

If the model can be an owner:

use Inventive\LaravelOwner\Traits\Owns;
	
class User extends Model
{
	use Owns;
}

If the model can be owned by another model:

use Inventive\LaravelOwner\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);

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固