Download the PHP package nhalstead/transferable without Composer
On this page you can find all versions of the php package nhalstead/transferable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nhalstead/transferable
More information about nhalstead/transferable
Files in nhalstead/transferable
Package transferable
Short Description Transfer attached relationships from one model instance to another model instance of the same type.
License MIT
Homepage https://github.com/nhalstead/transferable
Informations about the package transferable
Laravel Transferable Model Relationships
Make laravel model relationships transferable!
This is perfect to use when you want a model relationships to me assigned to another model (of the same type) and not be deleted or set null.
Install
How to use
On the model its self you need to add in the use statement and optionally add in the implements to block the model from being deleted.
By attaching the interface NoDanglingRelationships
you enable checks before deletion to ensure no relationships are connected that could be transferred.
What now?
We're able to block delete actions if we have relationships that can be transferred still attached, what now?
This package provides a few extra functions to all models that use TransferableRelationship
to make things easy and efficient.
If a model wants to transfer its relationships to another model you can use the example below:
What makes it efficient? This will use the model's relationship to determine what needs to be updated in the database and runs a query on the DB to update the relationships without any extra calls to get all the IDs and detaching things.
What else?
Nothing else, This package offers a few extra method for debugging and collecting information on the transferable relationships, see below: