PHP code example of grixu / socius-dto

1. Go to this page and download the library: Download grixu/socius-dto library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

grixu / socius-dto example snippets


class YourDto extends \Grixu\SociusDto\SociusDto
{
    // 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',
    'relations' => [
        [
            'foreignModel' => ForeignModel::class,
            'relation' => 'relationName',
            'foreignField' => 'xl_id',
            'type' => BelongsTo::class,
            'foreignKeys' => 'id',
        ],
    ]);