一键导入
laravel-laravel-prompting-patterns
Use Laravel-specific vocabulary—Eloquent patterns, Form Requests, API resources, jobs/queues—to get idiomatic framework code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use Laravel-specific vocabulary—Eloquent patterns, Form Requests, API resources, jobs/queues—to get idiomatic framework code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | laravel:laravel-prompting-patterns |
| description | Use Laravel-specific vocabulary—Eloquent patterns, Form Requests, API resources, jobs/queues—to get idiomatic framework code |
Use Laravel's vocabulary to get idiomatic code. Generic requests produce generic solutions that don't leverage the framework.
"Get all active users with their posts"
"Query active users with eager-loaded posts using Eloquent:
User::where('active', true)
->with('posts')
->get();
Add a scope to User model: scopeActive($query)"
"Set up a many-to-many relationship between Posts and Tags:
post_tag pivot table migrationbelongsToMany in Post modelbelongsToMany in Tag modelattach(), detach(), sync() for management""Avoid N+1 on the posts index:
author and category relationshipswithCount('comments') for comment totalspublished_at and category_id""Validate the user input"
"Create UserStoreRequest with validation rules:
public function rules(): array
{
return [
'email' => ['required', 'email', 'unique:users,email'],
'password' => ['required', 'min:12', Password::defaults()],
'name' => ['required', 'string', 'max:255'],
];
}
Add custom error messages in messages() method"
"Validate order creation:
Rule::exists('products', 'id') for product IDsitems.*.quantity must be integer, min 1Rule::requiredIf() for conditional shipping addressnew HasSufficientStock""Create an API for products"
"Create RESTful product API:
ProductController with apiResource routesProductResource for response transformationProductCollection for index endpoint with paginationauth:sanctumProductStoreRequest and ProductUpdateRequest for validation""Paginate products API:
Product::paginate(20) in controllerProductResource::collection($products)total, per_page, current_page, last_page?page=2 query parameter""Add filtering to products API:
?category=electronics&min_price=100 query paramswhen() for conditional queriesProductFilters class for reusability"Send email after user registers"
"Dispatch SendWelcomeEmail job after registration:
SendWelcomeEmail::dispatch($user)
->onQueue('emails')
->delay(now()->addMinutes(5));
ShouldQueue interface$tries = 3 and $timeout = 30failed() method$tags = ['user:'.$user->id]""Configure queue for payment processing:
redis connection for payments queuequeue:work --queue=payments,defaultretry_after to 90 seconds in config"Process order with job chain:
Bus::chain([
new ValidateInventory($order),
new ChargePayment($order),
new SendConfirmation($order),
])->dispatch();
If any job fails, chain stops. Handle in catch() callback."
"Implement according to Laravel's Eloquent Relationships docs"
"Follow Laravel's Form Request Validation pattern"
"Use Laravel's API Resource pattern for response transformation"
"Configure queues per Laravel Queue docs"
Models & Eloquent:
hasMany, belongsTo, belongsToMany, morphManyscopeActive, scopePublishedget{Attribute}Attribute, set{Attribute}Attributeprotected $casts = ['published_at' => 'datetime']Validation:
UserStoreRequest, ProductUpdateRequestrequired, unique:table,column, exists:table,columnnew Uppercase, Rule::in(['admin', 'user'])API:
UserResource, ProductCollectionpaginate(), simplePaginate(), cursorPaginate()throttle:60,1 middlewareJobs & Queues:
ShouldQueue, dispatch(), dispatchSync()Bus::chain(), Bus::batch()Use Laravel's vocabulary. Get Laravel solutions.
Build AI features with the first-party Laravel AI SDK (Laravel 13+); agents, embeddings, images, audio, and tool calling with provider-agnostic APIs
Use API Resources with pagination and conditional fields; keep response shapes stable and cache-friendly
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