Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Repository Laravel Package

giordanolima/eloquent-repository

A clean repository layer for Laravel Eloquent models. Wrap common query logic behind a simple, testable interface, keep controllers and services lean, and reuse filtering, pagination, and CRUD operations across your app. Swap implementations and mock queries easily in tests.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Repository abstraction (BaseRepository): Lets us standardize how the product's data layer is accessed, which makes it a reusable foundation for multiple features rather than one-off model code. PM value: it caps the marginal cost of each new CRUD surface, so we can add admin panels, list screens, and internal tooling without re-litigating architecture each time.
  • perPage property: Pagination becomes a declared, configurable default instead of an ad-hoc decision per endpoint. This is a product lever on list-heavy experiences — how much content a user sees per screen, and therefore how deep they scroll vs. filter.
  • orderBy property: A default sort is a product decision (what a user sees first), not a technical detail. Centralizing it means we can ship consistent ordering across surfaces and change ranking behavior in one place when we get feedback.
  • GlobalScope support: This directly enables product-level data visibility rules — multi-tenancy, soft-delete/archived content, published-vs-draft, per-plan data boundaries. PMs should treat this as a requirements surface: "who can see what" can now be enforced at the data layer rather than re-implemented in every query.
  • Cache driver: Turns caching into a configurable build-vs-buy and cost decision. For roadmap planning it is a performance/cost lever (infrastructure spend, perceived latency), and it introduces a freshness requirement we must state explicitly in the product spec.
  • Build vs. buy: Because this is a thin, opinionated base (1.0.0 with a small surface), it reads as a low-commitment starting point on top of Eloquent rather than a framework to migrate onto. That favors "buy/adopt" for standard CRUD workloads and "build" only where our domain logic is unusual.

When to Consider This Package

Adopt when:

  • The product is a conventional Laravel CRUD/API application with many similar list-and-detail resources where boilerplate is the dominant cost.
  • We want consistent pagination, ordering, and caching defaults across teams without enforcing a bespoke internal standard.
  • We have a multi-tenant, draft/published, or plan-gated product that benefits from a single enforcement point for visibility rules (GlobalScope).
  • Performance and database load matter enough that caching reads is on the roadmap, and we can accept eventual consistency within a defined TTL.
  • The team is comfortable with Eloquent conventions and wants a small abstraction layer, not an ORM replacement.

Look elsewhere or proceed cautiously when:

  • The domain needs rich query composition (criteria objects, complex joins, reporting/analytics queries) — a base repository tends to become a leaky catch-all.
  • We expect CQRS, event sourcing, or read/write split; a generic repository can fight those architectures.
  • The caching layer has no documented invalidation story yet — with only a "Cache driver" listed at 1.0.0, we need to confirm how writes invalidate cached reads, and whether cache keys are scope-aware. Caching data behind a GlobalScope without scope-aware keys is a data-leak risk, not just a stale-data risk.
  • Heavy transaction/write throughput is core; repository wrappers can obscure transaction boundaries.
  • There is no clear ownership: a small 1.0.0 package adds a dependency we may end up maintaining ourselves.

Open questions to resolve before adoption: default cache TTL and invalidation semantics, whether GlobalScope is opinionated (tenant-aware) or user-supplied, whether perPage/orderBy are safely overridable per request, and versioning/support posture for a 1.0.0.

How to Pitch It (Stakeholders)

Executive summary: This package is a small internal-standard-style building block for our Laravel services. It does not add user-facing features on its own; it reduces the cost and inconsistency of building list, detail, and admin screens, and gives us one place to control pagination defaults, default sort order, data visibility rules, and read caching. Expected benefit is faster delivery of standard CRUD surfaces and lower database load once caching is enabled — not new capability. It is a v1.0.0 with a deliberately thin surface, so the risk is low and reversible, but it is not a platform bet: it should be adopted as a convention, with our own tests around caching and visibility.

For engineering: Standardize on BaseRepository for conventional resources; define cache invalidation and scope-aware keys before enabling the cache driver in production; treat GlobalScope usage as a reviewed decision, since it changes what queries can see. Keep an escape hatch for complex queries rather than expanding the base class.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels