Answer the question
In order to leave comments, you need to log in
How to make connections and request in the controller correctly?
There are 3 tables "blud", "tproduct", "tproducts_attributes"
"blud" - stores a list of dishes
"tproduct" - stores a list of products
"tproducts_attributes" - a table for linking "blud" and "tproduct"
Please tell me how to make the links correctly in the many-to-many models (please check if I made the links correctly) and linked them in "tproducts_attributes" and how to correctly make a request in the controller to display only those lists of dishes that relate to the product (which are indicated in the "tproducts_attributes" table) ??
So far in the Controller I display like this (all dishes):
$values = Blud::find()->all();
Communication in the "blud" model:
public function getBluds()
{
return $this->hasMany(Blud::className(), ['blud_id' => 'id']);
}
public function getBluds()
{
return $this->hasMany(Blud::className(), ['tproduct_id' => 'id']);
}
public function getBlud()
{
return $this->hasOne(Blud::className(), ['id' => 'blud_id']);
}
public function getTproduct()
{
return $this->hasOne(Tproduct::className(), ['id' => 'tproduct_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