Easy Model - A Laravel package for enjoyably managing database queries

byโ€ข
๐Ÿ”ฅ Easy Model v2.1.0 is here! Simplify Laravel Eloquent with smarter filtering, sorting, relationships, eager loading, JSON and date filters, soft deletes, mass insert, and upsert support. Built to reduce repetitive code, improve flexibility, and keep your models clean and maintainable.

Add a comment

Replies

Best
Maker
๐Ÿ“Œ

๐Ÿš€ Easy Model v2.1.0 is here!

A major update bringing more powerful querying, filtering, relationships, and database operations to Laravel Eloquent.

๐Ÿ”Ž Request-Driven Queries

Build queries directly from request parameters with controlled filters, sorts, includes, and searches:

Product::fromRequest()
    ->allowedFilters(['status', 'category_id'])
    ->allowedSorts(['name', 'created_at'])
    ->allowedIncludes(['category'])
    ->allowedSearch(['name', 'description'])
    ->get();

โš™๏ธ Conditional Query Chaining

Conditionally add query logic with `when()` and `unless()`:

Product::when($active, fn ($query) => $query->where('active', true))
    ->unless($admin, fn ($query) => $query->where('public', true))
    ->get();

๐Ÿ”— Eager Loading & Relationships

Add relationships and relationship counts dynamically:

Product::addWith('category')
    ->addWithCount('reviews')
    ->get();

Keyword searches now also support dotted relationship columns:

Product::addKeywordSearch(['name', 'category.name'])->get();

๐ŸŽฏ Select, Pagination & SQL Inspection

Control selected columns, paginate results, and inspect generated SQL:

Product::addSelect(['id', 'name'])
    ->paginate(20);

Product::toSql();

Supports `paginate()`, `simplePaginate()`, and `cursorPaginate()`.

๐Ÿ“… Date, Period & JSON Filtering

Add powerful date, period, and JSON conditions:

Order::addWhereDate('created_at', '2026-09-01')
    ->addWherePeriod('created_at', $start, $end)
    ->addWhereJsonContains('options', ['featured' => true])
    ->get();

๐Ÿ—‘๏ธ Full Soft Delete Support

Work with trashed models and restore or permanently delete them:

User::onlyTrashed()->get();

$user->restore();

$user->forceDelete();

โšก Mass Insert & Upsert

Perform efficient bulk writes while optionally supporting model events:

Product::performInsert($products);

Product::performUpsert($products, ['sku']);

Product::usingModelEvents();

๐Ÿ”„ Smarter Relationship Ordering

Relationship joins in `addOrderBy()` now support table aliasing when multiple relationships use the same table.

๐Ÿงช Better Testing

v2.1.0 introduces an Orchestra Testbench and PHPUnit test suite to improve reliability and maintainability.

Easy Model v2.1.0 gives Laravel developers more control while reducing repetitive Eloquent query code.

Try it, explore the new features, and share your feedback!