diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index 00e9c1e..ad6089e 100644 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -10,6 +10,7 @@ use ElasticScoutDriverPlus\QueryDsl; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Support\Collection; use Laravel\Scout\Searchable; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\HasMedia; @@ -73,6 +74,7 @@ use Spatie\Tags\HasTags; * @property-read int|null $ingredient_separators_count * @method static \Database\Factories\RecipeFactory factory(...$parameters) * @method static \Illuminate\Database\Eloquent\Builder|Recipe whereTimeCook($value) + * @property-read Collection $ingredients_list */ final class Recipe extends Model implements HasMedia { @@ -162,6 +164,16 @@ final class Recipe extends Model implements HasMedia return round($this->weight / $this->servings, 2); } + /** + * Get the ingredients list (ingredient amounts and separators). + */ + public function getIngredientsListAttribute(): Collection { + return new Collection([ + ...$this->ingredientAmounts, + ...$this->ingredientSeparators, + ]); + } + /** * Get the steps for this Recipe. */ diff --git a/resources/views/recipes/show.blade.php b/resources/views/recipes/show.blade.php index 78254c0..f60d833 100644 --- a/resources/views/recipes/show.blade.php +++ b/resources/views/recipes/show.blade.php @@ -52,23 +52,34 @@
+ @if($item->text) +

{{ $item->text }}

+ @else +
+ @endif +
+