Download the PHP package pandorga/owner without Composer
On this page you can find all versions of the php package pandorga/owner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pandorga/owner
More information about pandorga/owner
Files in pandorga/owner
Package owner
Short Description Allow Eloquent models to own each other. Supports many to many relationships.
License MIT
Homepage https://github.com/pandorga/owner
Informations about the package 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:
- A user owning a blog post.
- A user and a team owning multiple files.
- 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:
Publish the migrations and config files:
Run the migrations:
Usage
Add necessary traits your Eloquent models:
If the model can be an owner:
If the model can be owned by another model:
Usage
"Owner" model:
Create an ownership:
Remove an ownership:
Return a collection of all the models owned by the parent model:
Does the user own this model?
Which models of this type does the parent model own? This method either takes a child model, or a name-spaced class name.
"Owned" model:
Return a collection of all the model's owners:
Is the model is owned by another model?
Add an owner to the model:
Remove an owner from the model
Remove all owners from the model
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.