grixu / relationship-data-transfer-object
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple class for wrapping data with relationships. But without those meta-data when dump DTO to Array
Package info
github.com/grixu/relationship-data-transfer-object
pkg:composer/grixu/relationship-data-transfer-object
2.0.0
2021-04-30 13:21 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0
- spatie/data-transfer-object: ^3.1
Requires (Dev)
- illuminate/database: ^8.0
- orchestra/testbench: ^6.15
- phpunit/phpunit: ^9.5
README
Simple class for wrapping data with relationships. But without those meta-data when dump DTO to Array
Installation
You can install the package via composer:
composer require grixu/relationship-data-transfer-object
Usage
class YourDto extends RelationshipDataTransferObject { // go forward as with normal DTO from spatie/data-transfer-object public string $some; } // Let's create one DTO object $dto = new YourDto([ 'some' => 'data', 'relationships' => [ [ 'localModel' => Model::class, 'foreignModel' => ForeignModel::class, 'localKey' => 'fk', 'foreignKey' => 'id', 'type' => BelongsTo::class, 'pivot' => [ 'field' => 'extra data' ] ], ... ]); // When you dump DTO to aaray it wouldn't contain relationships field $dto->toArray(); // But you can still access those data $dto->relationships;
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.