Mohamed Idris
@hnooz
Tips by @hnooz
Turn N+1 queries into errors in development with preventLazyLoading()
LARAVELCalled in a service provider, this throws a LazyLoadingViolationException whenever a relation is accessed without being…
Auto-delete stale records with the Prunable trait instead of a custom command
LARAVELAdd Prunable and a prunable() query, and model:prune (scheduled) deletes matching rows in chunks — no bespoke cleanup c…
Use whenLoaded() in API resources to avoid firing queries during serialization
LARAVELReferencing $this->posts directly in a resource lazy-loads the relation for every model when it wasn't eager-loaded — a…
Validate and convert date query params at the boundary with ParseDatePipe
NESTJSNestJS 11 ships ParseDatePipe, which validates an incoming date string and hands your handler a real Date. Parsing date…
Configure a strict global ValidationPipe to strip unknown fields and coerce DTOs
NESTJSwhitelist: true removes any property not declared with a validation decorator — your defense against mass-assignment, s…
Share state across components with useState, never a module-level ref, on SSR
NUXTOn the server a module-level ref is created once and shared by every request, so one user's cart can leak into another'…
Handle form mutations with built-in pending and error state via useActionState
REACTuseActionState wraps an async action and returns the last result, the action to bind to a <form action>, and a pending…
Replace modelValue/update boilerplate with defineModel() for v-model
VUEdefineModel() returns a writable ref wired to the parent's v-model, collapsing the modelValue prop plus update:modelVal…
Cancel stale async work in watchers with onWatcherCleanup()
VUERegistered inside the watcher callback, onWatcherCleanup runs before the next invocation and on stop. It removes the ma…
Generate hydration-safe unique IDs with useId() for accessibility
VUEuseId() produces IDs that are stable and identical across server render and client hydration, so label/for and aria-des…
Want to contribute? Submit a tip →