Class yii\shell\YiiCaster

Inheritanceyii\shell\YiiCaster
Available since version2.0
Source Code https://github.com/yiisoft/yii2-shell/blob/master/YiiCaster.php

YiiCaster provides wrapper for casters of psysh

Public Methods

Hide inherited methods

Method Description Defined By
castModel() Get an array representing the properties of a model. yii\shell\YiiCaster

Method Details

Hide inherited methods

castModel() public static method

Get an array representing the properties of a model.

public static array castModel ( yii\db\ActiveRecord $model )
$model yii\db\ActiveRecord

                public static function castModel(ActiveRecord $model)
{
    $attributes = array_merge(
        $model->getAttributes(), $model->getRelatedRecords()
    );
    $results = [];
    foreach ($attributes as $key => $value) {
        $results[Caster::PREFIX_VIRTUAL.$key] = $value;
    }
    return $results;
}