Skip to content

Instantly share code, notes, and snippets.

@osbre
Created December 1, 2025 17:08
Show Gist options
  • Select an option

  • Save osbre/d0bc8424339a9778ca7009e2e396f19c to your computer and use it in GitHub Desktop.

Select an option

Save osbre/d0bc8424339a9778ca7009e2e396f19c to your computer and use it in GitHub Desktop.
---
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