feat: meal post ingredients
This commit is contained in:
@@ -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')),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user