PHPackages                             pektiyaz/laravel-repository - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. pektiyaz/laravel-repository

ActiveLibrary[Framework](/categories/framework)

pektiyaz/laravel-repository
===========================

Repository implement for Laravel Framework

v1.0.1(10mo ago)0168MITPHP

Since Apr 8Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/pektiyaz/laravel-repository)[ Packagist](https://packagist.org/packages/pektiyaz/laravel-repository)[ RSS](/packages/pektiyaz-laravel-repository/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

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](https://github.com/pektiyaz)

---

✨ Features
----------

[](#-features)

- 🧩 Abstract base repository with out-of-the-box CRUD operations
- 🔁 Event-driven architecture (`created`, `updated`, `deleted`, `restored`, etc.)
- ♻️ Soft delete &amp; 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
--------------

[](#-installation)

```
composer require pektiyaz/laravel-repository
```

🧰 Usage
-------

[](#-usage)

1. Extend the AbstractRepository

```
use Pektiyaz\LaravelRepository\AbstractRepository;
/**
 * @method PostEntity findById(int|string $id)
 * @method PostEntity findOneBy(array $conditions)
 * @method PostEntity[] findAllBy(array $conditions)
 * @method PostEntity[] findAll()
 * @method PostEntity create(array $data)
 * @method PostEntity restore(int $id)
 * @method PostEntity[] paginate(int $page, int $perPage, array $conditions = [])
 * @method PostEntity[] findTrashed()
 * @method PostEntity findTrashedById(int|string $id)
 * @method PostEntity[] findByCallback(callable $callback)
 * @method PostEntity[] bulkCreate(array $records)
 * @method PostEntity[] filter(QueryFilterContract $filter)
 */
class PostRepository extends AbstractRepository
{
    public function getModel(): string
    {
        return \App\Models\Post::class;
    }

    public function getEntity(): string
    {
        return \App\Entities\PostEntity::class;
    }

    public function getEventPrefix(): string
    {
        return 'post';
    }
}
```

2. Create Your Entity

```
use Pektiyaz\LaravelRepository\AbstractEntity;

class PostEntity extends AbstractEntity
{
    protected ?string $title = null;

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(?string $title): void
    {
        $this->title = $title;
    }

    // Add other fields as needed...
}
```

🧠 Concepts
----------

[](#-concepts)

#### 📂 AbstractRepository

[](#-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

[](#-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

[](#-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

[](#-contracts-required)

This package relies on a few contracts to ensure consistency:

1. RepositoryContract
2. EntityContract
3. QueryFilterContract

These can be published or extended as needed for your application structure.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance53

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Total

2

Last Release

323d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4f2b8b44e78acb35b831cd7548f8670ae8a88ac477626008ba9224c4b0d5df2?d=identicon)[pektiyaz](/maintainers/pektiyaz)

---

Top Contributors

[![pektiyaz](https://avatars.githubusercontent.com/u/30262879?v=4)](https://github.com/pektiyaz "pektiyaz (12 commits)")

### Embed Badge

![Health badge](/badges/pektiyaz-laravel-repository/health.svg)

```
[![Health](https://phpackages.com/badges/pektiyaz-laravel-repository/health.svg)](https://phpackages.com/packages/pektiyaz-laravel-repository)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M674](/packages/laravel-socialite)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k84.2M225](/packages/laravel-horizon)[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M601](/packages/laravel-ui)[laravel/jetstream

Tailwind scaffolding for the Laravel framework.

4.1k19.8M136](/packages/laravel-jetstream)[stancl/tenancy

Automatic multi-tenancy for your Laravel application.

4.3k6.6M40](/packages/stancl-tenancy)[internachi/modular

Modularize your Laravel apps

1.1k662.4k8](/packages/internachi-modular)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
