What are models and how do I use them?
All models provided as part of the Aero core platform are Eloquent models
For example, if a module provided reviewsfor products, the reviewsmethod can be added to the Product model using a macro:
\Aero\Catalog\Models\Product::macro('reviews', function () {
return $this->hasMany(\Acme\MyModule\Models\Review::class);
});
The relationship query builder can be accessed by referencing the method:
$approvedReviewCount = $product->reviews()->where('approved', true)->count();
Just like a typical Eloquent relationship on a model, the resulting Collectionof reviews can be accessed through the magic property:
$reviews = $product->reviews;
{% for review in product.reviews %}
...
{% endfor %}