Answer the question
In order to leave comments, you need to log in
How to link independent tables in yii2?
There are 3 models:
public function getProducts()
{
return $this->hasMany(Product::className(), ['category_id' => 'id']);
}
Answer the question
In order to leave comments, you need to log in
public function getManufactures()
{
return $this->hasMany(Manufacturer::className(), ['id' => 'manufacturer_id'])
->viaTable('products');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question