generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
Some resources may have defined a with method to include additional fields in responses:
https://laravel.com/docs/12.x/eloquent-resources#top-level-meta-data
The generated spec misses those fields. Is this intended?
How to reproduce the bug
<?php
namespace App\Http\Resources\V1;
use App\Models\Task;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Task
*/
class TaskResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'user' => new UserResource($this->user),
'title' => $this->title,
'status' => $this->status,
'priority' => $this->priority,
/** @format date */
'due_date' => $this->due_date?->format('Y-m-d'),
'assignee' => new UserResource($this->assignee),
'tags' => TagResource::collection($this->tags),
];
}
/**
* @return array<string, mixed>
*/
public function with($request): array
{
return [
'data' => [
'description' => $this->description,
'created_at' => $this->created_at?->toRfc3339String(),
'updated_at' => $this->updated_at?->toRfc3339String(),
'metadata' => $this->metadata,
],
];
}
}
Package Version
0.12.34
PHP Version
8.4.12
Laravel Version
12.28.1
Which operating systems does with happen with?
macOS
Notes
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working