Download the PHP package pektiyaz/laravel-repository without Composer
On this page you can find all versions of the php package pektiyaz/laravel-repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pektiyaz/laravel-repository
More information about pektiyaz/laravel-repository
Files in pektiyaz/laravel-repository
Package laravel-repository
Short Description Repository implement for Laravel Framework
License MIT
Informations about the package laravel-repository
Laravel Repository π§±
A clean, extendable, and event-driven repository pattern implementation for Laravel applications. Easily separate your business logic from the persistence layer using a simple and powerful abstraction.
Built with β€οΈ by Pektiyaz
β¨ Features
- π§© Abstract base repository with out-of-the-box CRUD operations
- π Event-driven architecture (
created
,updated
,deleted
,restored
, etc.) - β»οΈ Soft delete & restore support
- π Powerful filtering with custom
QueryFilterContract
- ποΈ Entity abstraction with transformation helpers (
toArray
,toJson
, etc.) - π¦ Bulk operations (create, update, delete)
- π Pagination and advanced query support via callbacks
π¦ Installation
π§° Usage
-
Extend the AbstractRepository
- Create Your Entity
π§ Concepts
π AbstractRepository
The AbstractRepository provides a fully-featured base to handle:
- findById, findOneBy, findAllBy, findAll
- create, update, delete
- restore, forceDelete
- bulkCreate, bulkUpdate, bulkDelete
- paginate, exists, count
- filter, updateByFilter, deleteByFilter, countByFilter
Event dispatching with customizable prefixes
π§± AbstractEntity
The AbstractEntity provides a structured way to transform data between model and entity:
- toArray(), toJson() β Serialize entity
- fromArrayData(array $data) β Hydrate entity
- fromEntity(object $item) β Populate from another entity
-
fromJson(string $json) β Load from JSON
π Example Event Dispatching
If your repository uses an event prefix post, the following events will be dispatched automatically:
- post.entity.created
- post.entity.updated
- post.entity.deleted
- post.entity.restored
- post.entity.permanently_deleted
Use Laravelβs event listeners to handle these events for logging, syncing, notifications, etc.
π§ Contracts Required
This package relies on a few contracts to ensure consistency:
- RepositoryContract
- EntityContract
- QueryFilterContract
These can be published or extended as needed for your application structure.
All versions of laravel-repository with dependencies
pektiyaz/repository-contracts Version ^1.0