π Easy Model v2.1.0 is here!
Eloquent makes simple queries easy. But as an application grows, the same filtering, sorting, searching, eager loading, pagination, and relationship logic can start appearing across multiple controllers and repositories.
A typical endpoint can quickly turn into a long chain of conditional query logic:
$query = User::query();
$query->when($request->filled('search'), function ($query) use ($request) {
$query->where('name', 'like', '%' . $request->search . '%');
});
$query->when($request->filled('sort'), function ($query) use ($request) {
$query->orderBy($request->sort, $request->direction ?? 'asc');
});
$query->with($request->input('include', []));
$users = $query->paginate($request->input('per_page', 15));
Easy Model helps move this kind of repetitive query logic into reusable model capabilities.
For example, request-driven queries can handle filters, sorting, includes, and searches:
$users = User::fromRequest()->paginate();
You can also build more specific queries with dedicated methods:
User::query()
->whereDateBetween('created_at', $from, $to)
->whereJson('settings->role', 'admin')
->withCount('posts')
->orderByRelationship('posts', 'created_at')
->paginate();
Whatβs new in v2.1.0
- π Request-Driven Queries β build controlled filters, sorts, includes, and searches from request parameters.
- βοΈ Conditional Queries β apply query logic with
when()andunless(). - π Smarter Relationships β dynamic eager loading, relationship counts, and relationship-based keyword searches.
- π― Select & Pagination β control selected columns and use multiple pagination strategies.
- π Date & JSON Filters β query dates, periods, and JSON data with dedicated methods.
- ποΈ Soft Deletes β query, restore, and permanently delete soft-deleted models.
- β‘ Mass Insert & Upsert β handle bulk database operations with optional model events.
- π Relationship Ordering β improved joins and table aliasing for complex relationship queries.
- π§ͺ Better Testing β expanded coverage with Orchestra Testbench and PHPUnit.
The goal is simple: reduce repetitive Eloquent code while giving developers more control over complex queries.
π Check out Easy Model:

Top comments (0)