sam-it/yii2-jsonbehavior

This package is abandoned and no longer maintained. No replacement package was suggested.

Advanced AR JSON support

Maintainers

👁 SamMousa

Package info

github.com/SAM-IT/yii2-jsonbehavior

pkg:composer/sam-it/yii2-jsonbehavior

Statistics

Installs: 18 408

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 10

v2.0.0 2020-06-01 11:26 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 528415787ce35137e8da1df98a44570d5d7fdc94

  • Sam Mousa <sam.woop@mousa.nl>
  • Joey Claessen <joey_claessen.woop@hotmail.com>

README

👁 Scrutinizer Code Quality
👁 Code Coverage
👁 Build Status
👁 Total Downloads
👁 Latest Stable Version

Yii2 JsonBehavior

Work with JSON fields in Yii2

This behavior adds advanced support for working with JSON data in Yii AR models.

Use JSON fields like normal fields

Consider a model having a data attribute that is stored as JSON.

public function behaviors() {
 return [
 ['class' => JsonBehavior::class, 'jsonAttributes' => ['data']]
 ];
}

// Examples:
$model = new Model();
$model->a = "test"; // If attribute 'a' does not exist this is stored inside the data.

$model->a['b'] = 'c']; // Nested arrays are supported.

$model->data = ['x' => 'y']; // Assigning directly is supported.