2017 © Pedro Peláez
 

cakephp-plugin persist-related-data

CakePHP ORM plugin for persisting selected fields of related tables

image

riesenia/persist-related-data

CakePHP ORM plugin for persisting selected fields of related tables

  • Thursday, July 12, 2018
  • by riesenia
  • Repository
  • 4 Watchers
  • 10 Stars
  • 601 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 10 Versions
  • 20 % Grown

The README.md

PersistRelatedData behavior for CakePHP

Build Status Latest Version Total Downloads Software License, (*1)

This plugin is for CakePHP 3.x and contains behavior that handles saving selected fields of related data (redundantly)., (*2)

Installation

Update composer.json file to include this plugin, (*3)

{
    "require": {
        "riesenia/persist-related-data": "~1.0"
    }
}

Load plugin in config/bootstrap.php, (*4)

Plugin::load('PersistRelatedData');

Usage

Good example for using this behavior is Invoices model that is related to Contacts. You can provide select box with contacts and save only contact_id when creating new invoice. But when contact data are modified later, your invoice should be left intact., (*5)

Example below assumes the invoices table has fields contact_id, contact_name and contact_address, while the contacts table has fields name and address. When you save Invoice entity with provided contact_id, fields contact_name and contact_address will be filled automatically., (*6)

class InvoicesTable extends Table
{
    public function initialize(array $config)
    {
        parent::initialize($config);

        // add PersistRelatedData behavior
        $this->addBehavior('PersistRelatedData.PersistRelatedData', [
            'fields' => [
                'contact_name' => 'Contacts.name',
                'contact_address' => 'Contacts.address'
            ]
        ]);

        // associations
        $this->belongsTo('Contacts', [
            'foreignKey' => 'contact_id',
            'className' => 'Contacts'
        ]);
    }
}

The Versions

12/07 2018

dev-master

9999999-dev

CakePHP ORM plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

orm cakephp related materialize

12/07 2018

v1.1.0

1.1.0.0

CakePHP ORM plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

orm cakephp related materialize

08/12 2016

v1.0.7

1.0.7.0

CakePHP ORM plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

orm cakephp related materialize

06/12 2016

v1.0.6

1.0.6.0

CakePHP ORM plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

orm cakephp related materialize

25/07 2016

v1.0.5

1.0.5.0

CakePHP ORM plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

orm cakephp related materialize

23/07 2016

v1.0.4

1.0.4.0

CakePHP ORM plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

orm cakephp related materialize

21/01 2016

v1.0.3

1.0.3.0

CakePHP ORM plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

orm cakephp related materialize

06/11 2015

v1.0.2

1.0.2.0

CakePHP plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

16/07 2015

v1.0.1

1.0.1.0

CakePHP plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy

11/06 2015

v1.0.0

1.0.0.0

CakePHP plugin for persisting selected fields of related tables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomas Saghy