Good evening.
I wonder if someone could guide me in this situation.
I am creating a plugin, and it has a model class, in which it can have a image or not.
How I run the query to list all the records that have an image...
Ex:
-- myPlugin/models/MyModel.php
class MyModel extends Model
{
...
public $attachOne = [
'image' => ['System\Models\File']
];
}
-- myPlugin/components/MyComponentController.php
class MyComponentController extends ComponentBase
{
protected function listSlides()
{
$records = MyModel::magicQueryThatSolveMyProblem();
return $records;
}
}
-- myPlugin/components/mycomponent/default.htm
{% for record in records %}
<p>
<img src="{{record.image.getPath()}}" />
</p>
{% else %}
<p class="no-data">No images</[>
{% endfor %}
Last updated