/** * Defines the relationship with the pizzas */ public function getPizza() { return $this->hasOne(Pizza::className(), ['id' => 'pizza_id']); }
/** * Defines the relationship with the pizzas */ public function getPizzas() { return $this->hasMany(Pizza::className(), ['id' => 'pizza_id'])->via('pizzaIngredients'); // the relationship needs the junction table to work }