laracraft-tech/laravel-useful-traits
Laravel package with handy daily-use additions: traits for PHP 8.1+ enums (get names/values/array) and Eloquent query scopes (e.g., select all columns except specific ones, date-based scopes), plus an Artisan db:truncate command.
UsefulEnums cuts down boilerplate for iterating over enum values, while UsefulScopes standardizes query logic like time-based filtering.selectAllBut for dynamic column selection) across the codebase, ensuring consistency and reducing ad-hoc implementations. This aligns with initiatives to improve code maintainability and scalability.db:truncate command streamlines database cleanup in CI/CD pipelines, while the deprecated RefreshDatabaseFast (replaced by Laravel’s built-in trait) highlights a shift toward optimized testing workflows. This supports roadmap items focused on reducing flaky tests and improving test suite reliability.db:truncate command can be integrated into deployment pipelines to reset databases efficiently, supporting scalability goals.selectAllBut).For Executives: "This package is a low-risk, high-reward tool to supercharge our Laravel development. It eliminates repetitive code for common tasks—like managing enums or querying data—so our team can focus on building features faster. For example, it cuts down the time spent writing boilerplate for status filters or database resets, which directly impacts our sprint velocity. The MIT license and active maintenance mean we’re not locked into a proprietary solution, and the package aligns with our roadmap for scalable, maintainable code. It’s a small investment (composer install) with measurable gains in developer productivity."
For Engineering Teams: *"This package provides three key benefits:
UsefulEnums trait lets you loop over enum values or convert them to arrays with one line of code—no more manual case mappings. Ideal for statuses, roles, or any typed constants.UsefulScopes gives you out-of-the-box scopes like fromToday(), fromYesterday(), and selectAllBut(), which we can standardize across the codebase. This reduces duplication and makes queries more predictable.db:truncate command speeds up database resets in CI/CD, and while RefreshDatabaseFast is deprecated, we can now rely on Laravel’s built-in trait for the same performance gains.
It’s battle-tested, actively maintained, and integrates seamlessly with Laravel 11+. Let’s prototype it in [Project X] to see how it reduces our query boilerplate by 20%—I’ll share a spike report in two weeks."*How can I help you explore Laravel packages today?