GithubHelp home page GithubHelp logo

divineomega / uxdm-spatie-data-transfer-object Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 16 KB

๐Ÿ”€ Spatie Data Transfer Object source and destination for the UXDM data migrator

PHP 100.00%
uxdm spatie-data-transfer spatie data-transfer-object

uxdm-spatie-data-transfer-object's Introduction

๐Ÿ”€ UXDM Spatie Data Transfer Object

Build Status Coverage Status

The UXDM Spatie Data Transfer Object package provides a UXDM source and destination for Data Transfer Objects that are created using the Spatie Data Transfer Object package.

If you have not used UXDM before to migrate your data, visit the UXDM GitHub repository to learn more.

Installation

To install the UXDM Spatie Data Transfer Object package, just run the following composer command.

composer require divineomega/uxdm-spatie-data-transfer-object

UXDM Spatie Data Transfer Object Source

The UXDM Spatie Data Transfer Object source allows you to source data from a Spatie Data Transfer Object Collection.

Creating

To create a new Spatie Data Transfer Object source, you must provide it with a populated Spatie Data Transfer Object Collection.

The following example creates a Spatie Data Transfer Object source object, using a collection of users data transfer objects.

$users = new UserDTOCollection([
    new UserDTO([
        'id' => 1,
        'name' => 'Picard`',
        'email' => '[email protected]',
    ]),
    new UserDTO([
        'id' => 2,
        'name' => 'Janeway',
        'email' => '[email protected]',
    ])
]);

$spatieDataTransferObjectSource = new SpatieDataTransferObjectSource($users);

Assigning to migrator

To use the Spatie Data Transfer Object source as part of a UXDM migration, you must assign it to the migrator. This process is the same for most sources.

$migrator = new Migrator;
$migrator->setSource($spatieDataTransferObjectSource);

UXDM Spatie Data Transfer Object Destination

The UXDM Spatie Data Transfer Object destination allows you to migrate data into a Spatie Data Transfer Object Collection.

Creating

To create a new Spatie Data Transfer Object destination, you must provide it with a Spatie Data Transfer Object Collection, and the class name of a Spatie Data Transfer Object.

The following example creates a Spatie Data Transfer Object destination object, using an empty collection, and the name of a user data transfer object class.

$users = new UserDTOCollection();
$spatieDataTransferObjectDestination = new SpatieDataTransferObjectDestination($users, UserDTO::class);

Assigning to migrator

To use the Spatie Data Transfer Object destination as part of a UXDM migration, you must assign it to the migrator. This process is the same for most destinations.

$migrator = new Migrator;
$migrator->setDestination($spatieDataTransferObjectDestination);

Alternatively, you can add multiple destinations, as shown below. You can also specify the fields you wish to send to each destination by passing an array of field names as the second parameter.

$migrator = new Migrator;
$migrator->addDestination($spatieDataTransferObjectDestination, ['field1', 'field2']);
$migrator->addDestination($otherDestination, ['field3', 'field2']);

uxdm-spatie-data-transfer-object's People

Contributors

divineomega avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.