ワンクリックで
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 職業分類に基づく
| 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 fieldsHigh-level architecture decisions, patterns, and project structure. Use when deciding which pattern to use, organizing code, or making structural decisions.
Background jobs and event listeners for async processing. Use when creating or modifying jobs, queues, listeners, or event-driven workflows.
Package development and extraction of reusable code. Use when creating, extracting, or modifying composer packages.
Service providers, bootstrapping, and application configuration. Use when modifying service providers, booters, bootstrap logic, or app-level configuration.
Code quality tooling with PHPStan, Pint, and strict types. Use when configuring or running static analysis, code style, or linting.
Route configuration, route model binding, and authorization. Use when defining routes, configuring model binding, or setting up route-level authorization.