Created
December 1, 2025 17:08
-
-
Save osbre/d0bc8424339a9778ca7009e2e396f19c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| globs: **/*.php | |
| alwaysApply: false | |
| --- | |
| - Do not use `auth()` helper or `Auth` facade, instead always retrieve the user either from the Request (`$request->user()`) or via `#[CurrentUser]` attribute (`use Illuminate\Container\Attributes\CurrentUser;`). Prop-drill it down the methods instead of calling `Auth` or `auth`. | |
| - Do not add comments because code is already self-explanatory. | |
| - Do not assign ids manually like `Post::create(['user_id' => Auth::id()`, instead call relationship method on the parental model like `$user->posts()->create()`. | |
| - Do not query ids manually like `where('user_id', $user->id)`, always prefer methods such as `whereBelongsTo($user)`, or `whereAttachedTo($role)`. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment