tpetry/laravel-query-expressions
Add powerful SQL expression support to Laravel’s query builder. Compose reusable, type-safe expressions for functions, casts, JSON ops, windows, and more, with clean syntax and cross-database compatibility—ideal for advanced filtering, sorting, and computed columns.
DB::raw()) can be incrementally replaced without breaking changes, though some edge cases (e.g., dynamic SQL generation) may need refactoring.CASE WHEN logic) might require custom expression builders, adding minor development effort.roave/security-advisories or manual code reviews to identify high-risk or complex queries.DB::raw() calls with expressive syntax.// Before
DB::table('users')->whereRaw('age > ? AND status = ?', [$age, $status]);
// After
DB::table('users')
->where('age', '>', $age)
->where('status', '=', $status);
JSON_EXTRACT), create custom expression classes extending Tpetry\QueryExpressions\Expressions\Expression.DatabaseMigrations or DatabaseTransactions traits.DB::enableQueryLog() to verify generated SQL matches expectations.spatie/laravel-query-builder). Test thoroughly.WHERE, JOIN, and ORDER BY clauses in CRUD operations.DB::connection()->enableQueryCache()).How can I help you explore Laravel packages today?