PHPackages                             imjonos/laravel-base-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. imjonos/laravel-base-repository

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

imjonos/laravel-base-repository
===============================

Laravel base repository

1.1.4(2mo ago)08681MITPHP

Since Aug 17Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/imjonos/laravel-base-repository)[ Packagist](https://packagist.org/packages/imjonos/laravel-base-repository)[ Docs](https://github.com/imjonos/laravel-base-repository)[ RSS](/packages/imjonos-laravel-base-repository/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (6)Versions (11)Used By (1)

📦 Laravel Base Repository
=========================

[](#-laravel-base-repository)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2257fdd78d554757edc5a3f444613a4312f4f3e42b0b99be40138295992a59b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6a6f6e6f732f6c61726176656c2d626173652d7265706f7369746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/imjonos/laravel-base-repository)
[![Total Downloads](https://camo.githubusercontent.com/2588608893dc74ac312e256474146c15d1da8200dbab68bec2ffa82fe5647f62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d6a6f6e6f732f6c61726176656c2d626173652d7265706f7369746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/imjonos/laravel-base-repository)

A **generic base repository class** for Laravel projects that provides a clean and consistent way to interact with Eloquent models. It simplifies CRUD operations and makes your code more maintainable, testable, and scalable.

---

🧩 Overview
----------

[](#-overview)

This package provides an abstract `EloquentRepository` class that implements the `EloquentRepositoryInterface`. It wraps common model interactions into reusable methods, making it easier to manage data access logic in your Laravel applications.

---

🛠 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require imjonos/laravel-base-repository
```

---

✅ Usage
-------

[](#-usage)

### 1. Create Your Repository Class

[](#1-create-your-repository-class)

Create a new repository class that extends `EloquentRepository` and specifies the model class:

```
namespace App\Repositories;

use App\Models\Order;
use Nos\BaseRepository\EloquentRepository;

class OrderRepository extends EloquentRepository
{
    protected string $class = Order::class;
}
```

> **Note:** If you use Laravel Scout with the `Searchable` trait on your model, the repository will automatically keep the search index in sync.

### 2. Use the Repository in a Controller or Service

[](#2-use-the-repository-in-a-controller-or-service)

Inject the repository and use its methods:

```
namespace App\Http\Controllers;

use App\Repositories\OrderRepository;
use Illuminate\Http\Request;

class OrderController extends Controller
{
    protected $repository;

    public function __construct(OrderRepository $repository)
    {
        $this->repository = $repository;
    }

    public function index()
    {
        $orders = $this->repository->all();
        return view('orders.index', compact('orders'));
    }

    public function store(Request $request)
    {
        $order = $this->repository->create($request->all());
        return redirect()->route('orders.show', $order->id);
    }
}
```

---

🔧 Available Methods
-------------------

[](#-available-methods)

MethodDescription`all()`Get all records`count()`Count all records`create(array $data)`Create a new record`update(int $id, array $data)`Update a record by ID`exists(int $id)`Check if a record exists`find(int $id)`Find a record by ID (returns null if not found)`delete(int $id)`Delete a record by ID`query()`Return a query builder instance for custom queries`insert(array $data)`Insert multiple records (no events, no scout)`upsert(array $values, array| string $uniqueBy, ?array $update)`Update or insert multiple records### 🔍 Laravel Scout Support

[](#-laravel-scout-support)

The repository automatically handles Laravel Scout indexing when using the `Searchable` trait:

- After `upsert()`: Makes records searchable
- After `update()`: Updates search index
- After `delete()`: Removes from search index

---

🌐 Project Structure
-------------------

[](#-project-structure)

```
src/
├── EloquentRepository.php
└── Interfaces/
    └── EloquentRepositoryInterface.php

```

---

📦 Requirements
--------------

[](#-requirements)

- PHP 8.0+
- Laravel 5.0+ - 13.x

---

🧪 Testing
---------

[](#-testing)

You can easily mock the repository interface in your tests, which helps keep your application logic decoupled from the database and improves test coverage.

---

🚀 Contributing
--------------

[](#-contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

---

📝 License
---------

[](#-license)

This package is open-sourced software licensed under the MIT license. Please see the [license file](license.md) for more information.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance85

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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 ~190 days

Recently: every ~274 days

Total

8

Last Release

87d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a691ecb149ac661add3a6229e3c545aaaa40bad4ae0fa9c0ad9464c79e86ff20?d=identicon)[Eugeny Nosenko](/maintainers/Eugeny%20Nosenko)

---

Top Contributors

[![imjonos](https://avatars.githubusercontent.com/u/5132976?v=4)](https://github.com/imjonos "imjonos (16 commits)")

---

Tags

laravelrepository

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[venturedrake/laravel-crm

A free open source CRM built as a package for laravel projects

43311.2k](/packages/venturedrake-laravel-crm)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k12.5k1](/packages/vinkius-labs-laravel-page-speed)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90142.9k](/packages/emargareten-inertia-modal)

PHPackages © 2026

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