Add custom attribute to standard element from plugin Developing plugin for Craft 3, I want to add extra property to Assets (data being pulled from other table)

I am able to pull in the data by extending element query:

Event::on(
            ElementQuery::class,
            ElementQuery::EVENT_AFTER_PREPARE,
            function(CancelableEvent $e) {
                if ($e-&gt;sender-&gt;elementType == 'craft\\elements\\Asset')
                {
                    $e-&gt;sender-&gt;query-&gt;addSelect('linkstats.downloads');

                    $subQuery = (new Query())
                        -&gt;select('assetId, SUM(downloads) AS downloads')
                        -&gt;from('{{%my_plugin_table}}')
                        -&gt;groupBy('assetId');

                    $e-&gt;sender-&gt;query-&gt;leftJoin(
                        ['linkstats' =&gt; $subQuery], 'assets.id = linkstats.assetId'
                    );
                }
            }
        );


However when trying to display the asset I get error:


  Setting unknown property: craft\elements\Asset::downloads


Question, how do I register this new property/attribute for Assets? I cannot find any event to do that, is it possible at all?
Another approach is to use the following event to attach a behavior

Event::on(Asset::class, Asset::EVENT_DEFINE_BEHAVIORS, 
function(DefineBehaviorsEvent $event) {
    $event-&gt;behaviors[] = MyBehavior::class;
});


The behavior could look like

class MyBehavior extends Behavior { 
    public $downloads; 
}


This way you won't receive an exception and can access your property via

$asset = Assets::find()-&gt;all();
$asset-&gt;downloads;


You can as well manipulate the value of downloads in the Behaviors init function in order to return the file or something like this