/** * Defines the relationship with the ingredients */ public function getIngredient() { return $this->hasOne(Ingredient::className(), ['id' => 'ingredient_id']); }
/** * Defines the relationship with the ingredients */ public function getIngredients() { return $this->hasMany(Ingredient::className(), ['id' => 'ingredient_id'])->via('pizzaIngredients'); // the relationship needs the junction table to work }