I am trying to make a virtual attribute with the published assetpath in a model like:
public function getUrlwithassetpath()
// First publish the asset
$asset = Asset::register($this);
// get the baseUrl
$pad = $asset->baseUrl;
// strip all (incorrect) paths in the field url
$urlwithoutextension = pathinfo($this->url)['filename'];
// give the correct path back
However, the line Asset::register($this) gives an error. I am in a model, not a view, that is why.
But I need the path in this virtual attribute. How can I get the Asset path in a model?
P.S. the topic line is incorrect. This is in the model, not the controller. I can not edit the topic line?