원클릭으로
laravel-api-resources-and-pagination
Use API Resources with pagination and conditional fields; keep response shapes stable and cache-friendly
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use API Resources with pagination and conditional fields; keep response shapes stable and cache-friendly
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Build AI features with the first-party Laravel AI SDK (Laravel 13+); agents, embeddings, images, audio, and tool calling with provider-agnostic APIs
Compose UIs with Blade components, slots, and layouts; keep templates pure and testable
Request effective code reviews—specify focus areas, provide context, ask for architectural feedback, reference Laravel conventions
Practical daily checklist for Laravel projects; bring services up, run migrations, queues, quality gates, and tests
Create effective debugging prompts—include error messages, stack traces, expected vs actual behavior, logs, and attempted solutions
Provide comprehensive context in prompts—files, errors, Laravel version, dependencies, and monorepo details—for accurate AI responses
| name | laravel:api-resources-and-pagination |
| description | Use API Resources with pagination and conditional fields; keep response shapes stable and cache-friendly |
Represent models via Resources; keep transport concerns out of Eloquent.
# Resource
sail artisan make:resource PostResource # or: php artisan make:resource PostResource
# Controller usage
return PostResource::collection(
Post::with('author')->latest()->paginate(20)
);
# Resource class
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->title,
'author' => new UserResource($this->whenLoaded('author')),
'published_at' => optional($this->published_at)->toAtomString(),
];
}
Resource::collection($query->paginate()) over manual arrayswhen() / mergeWhen() for conditional fieldsFirst-party JSON:API resources handle resource objects (type/id/attributes/relationships), ?include= relationship inclusion, ?fields[...]= sparse fieldsets, links, and application/vnd.api+json headers.
class PostJsonApiResource extends JsonApiResource
{
public function toArray($request)
{
return [
'type' => 'posts',
'id' => $this->id,
'attributes' => ['title' => $this->title, 'body' => $this->body],
'relationships' => ['author' => new UserJsonApiResource($this->author)],
];
}
}
included/sparse-fieldset logic on top of plain Resources — use the first-party classes