public function getMagnesium() { $nutrient = $this->nutrients()->whereNutrientId(Nutrient::Magnesium()->getID())->first(); return $nutrient != null ? $nutrient->pivot->amount_in_food : 0; }