28 lines
726 B
PHP
28 lines
726 B
PHP
<?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')),
|
|
];
|
|
}
|
|
}
|