mvanduijker/laravel-model-exists-rule
post_id in a Comment model must exist in Posts).whereDoesntHave or whereNotNull).User must have an active Subscription).update_user_profile where user_id must exist).Adopt When:
Rule::exists() is insufficient (e.g., needs joins, whereHas, or soft-delete checks).Order → Customer → Address).Look Elsewhere If:
Rule::exists() or Eloquent’s findOrFail).For Executives: "This package lets us validate that database records exist before processing user actions—like ensuring a user can’t delete a non-existent order or update a profile tied to an invalid customer. It’s a lightweight, battle-tested solution that reduces bugs in critical workflows, saving support costs and improving reliability. Think of it as a ‘guardrail’ for our data integrity, with minimal engineering lift."
For Engineering:
*"This replaces ad-hoc try-catch blocks or manual Model::find() checks in validation logic with a clean, reusable rule. Key benefits:
whereHas, and soft deletes out of the box.if (!$user = User::find($request->user_id)) { abort(404); }, we’ll use new ModelExists(User::class)—cleaner and more scalable."*How can I help you explore Laravel packages today?