Answer the question
In order to leave comments, you need to log in
How to make a hasMany link with a photo of goods for an online store?
Hello dear programmers! =)
Situation (a little exaggeration for simplicity):
There is a table product, there is a model Product [id, name]
There is a table product_photos [id, product_id, url]
How can I make a hasMany relationship for the product table with the product_photos table? Do I need to create an ActiveRecord model for the product_photos table?
Perhaps the question will seem strange, so I will explain why I ask this way. To link categories with products, the following construction is used, which is written in the Catalog model:
public function getProduct()
{
return $this->hasMany(Product::className(), ['catalog_id' => 'id']);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question