How to add to arrays in models? I have a model that contains a bunch of storage arrays where I collect results from various services I have written.

class Shipper_ResultsModel extends BaseModel
{


shipping categories for debugging

    protected function defineAttributes()
    {
        return array(
            'service'               =&gt; array('type'=&gt;AttributeType::Enum, 'values'=&gt;['post','courier','free','cantShip','needsQuote']),
            'options'               =&gt; array('type'=&gt;AttributeType::Mixed,'default'=&gt;[]),
            'boxes'                 =&gt; array('type'=&gt;AttributeType::Mixed,'default'=&gt;[]),
            'postShippingItems'     =&gt; array('type'=&gt;AttributeType::Mixed,'default'=&gt;[]),
            'courierShippingItems'  =&gt; array('type'=&gt;AttributeType::Mixed,'default'=&gt;[]),
            'freeShippingItems'     =&gt; array('type'=&gt;AttributeType::Mixed,'default'=&gt;[]),
            'cantShippingItems'     =&gt; array('type'=&gt;AttributeType::Mixed,'default'=&gt;[]),
            'quoteShippingItems'    =&gt; array('type'=&gt;AttributeType::Mixed,'default'=&gt;[]),
        );
    }


Each of this ShippingItems arrays is intended to hold an array of Shipper_ShippingItem models.

My issue is in building these arrays, I create new items and add them like this:

            $shippingItem = Shipper_ShippingItemModel::populateModel($data);

            //build our arrays of items
            if($shippingClass=="Courier Only"){
                $results-&gt;courierShippingItems[] = $shippingItem;
            }


But this results in the following error:

PHP Notice: Indirect modification of overloaded property Craft\Shipper_ResultsModel::$courierShippingItems has no effect


I think this is because I am not using array objects as such but I have to say I've  got a little confused here and various syntax experiments have resulted in ignoble failures.

Some guidance as to the right way would be much appreciated (and am I right in using AttributeType::Mixed for these?)

(This is all for a mega shipping calculator for Craft Commerce, should that matter)
I'm pretty sure 'default'=&gt;[] isn't doing anything so it's probably not necessary.

If you wanted to force a single attribute to be of a specific model, you could use:

'courierShippingItems'  =&gt; array('type' =&gt; AttributeType::Mixed, 'model' =&gt; 'Shipper_ShippingItemModel');


Regardless, you'll want to use BaseModel's setAttribute to do what you're trying to do and build your entire array up first before assigning it to the attribute.  Something like this:

$shippingItems[] = Shipper_ShippingItemModel::populateModel($data);

$results-&gt;setAttribute('courierShippingItems', $shippingItems);