feat: meal post ingredients

This commit is contained in:
2026-05-18 14:39:57 +02:00
parent 7916e7f718
commit 7a907f2b17
12 changed files with 404 additions and 10 deletions
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources;
use App\Models\MealPostIngredients;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin MealPostIngredients */
class MealPostIngredientsResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'position' => $this->position,
'ingredient' => $this->ingredient,
'unit' => $this->unit,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'meal_posts_id' => $this->meal_posts_id,
'mealPosts' => new MealPostsResource($this->whenLoaded('mealPosts')),
];
}
}
+1
View File
@@ -29,6 +29,7 @@ class MealPostsResource extends JsonResource
'eatenAt' => $this->eaten_at,
'createdAt' => $this->created_at,
'updatedAt' => $this->updated_at,
'ingredients' => MealPostIngredientsResource::collection($this->whenLoaded('ingredients')),
'user' => [
'name' => $user?->name,