搜索

PythonReactSEOPDF
GitHub Skill

laravel

Avoid common Laravel mistakes — N+1 queries, mass assignment, cache gotchas, and queue serialization traps.

openclaw☆ 2,396 仓库 Stars711 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Quick Reference

Topic File
N+1 queries, eager loading, accessors, observers eloquent.md
Validation, middleware order, dependency injection controllers.md
Job serialization, retries, failed jobs queues.md
Guards, policies, gates, Sanctum tokens auth.md
XSS escaping, components, slots blade.md
Commands, scheduling, tinker artisan.md

Critical Rules

  • Eager load relationships — with('posts') not lazy ->posts in loop (N+1)
  • preventLazyLoading() in dev AppServiceProvider — crashes on N+1, catches early
  • env() only in config files — returns null after config:cache
  • $fillable whitelist fields — $guarded = [] allows mass assignment attacks
  • find() returns null — use findOrFail() to avoid null checks
  • Job properties serialize models as ID — re-fetched on process, may be stale/deleted
  • route:cache requires controller routes — closures break cached routes
  • DB::transaction() doesn't catch exit/timeout — only exceptions roll back
  • RefreshDatabase uses transactions — faster than DatabaseMigrations
  • {!! $html !!} skips escaping — XSS vector, use {{ }} by default
  • Middleware order matters — earlier middleware wraps later execution
  • required validation passes empty string — use required|filled for content
  • firstOrCreate persists immediately — firstOrNew returns unsaved model
  • Route model binding uses id — override getRouteKeyName() for slug

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-03-11
索引更新时间
2026-03-11
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!