id = $data['id'] ?? null; $dto->ingredientId = isset($data['ingredientId']) ? (int)$data['ingredientId'] : null; $dto->ingredientName = $data['ingredientName'] ?? null; $dto->ingredientSlug = $data['ingredientSlug'] ?? null; $dto->ingredientCategory = $data['ingredientCategory'] ?? null; $dto->quantity = $data['quantity'] ?? null; $dto->unit = $data['unit'] ?? null; $dto->notes = $data['notes'] ?? null; $dto->sortOrder = isset($data['sortOrder']) ? (int)$data['sortOrder'] : null; return $dto; } /** * Convert DTO to array * * @return array */ public function toArray(): array { return [ 'id' => $this->id, 'ingredientId' => $this->ingredientId, 'ingredientName' => $this->ingredientName, 'ingredientSlug' => $this->ingredientSlug, 'ingredientCategory' => $this->ingredientCategory, 'quantity' => $this->quantity, 'unit' => $this->unit, 'notes' => $this->notes, 'sortOrder' => $this->sortOrder, ]; } }