PHPackages                             thaile/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. thaile/repository

ActiveLibrary[Framework](/categories/framework)

thaile/repository
=================

The Laravel Framework Plugin.

04PHP

Since Jan 10Pushed 7y agoCompare

[ Source](https://github.com/thaile0101/repository-plugin)[ Packagist](https://packagist.org/packages/thaile/repository)[ RSS](/packages/thaile-repository/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

ThaiLe Repository package
=========================

[](#thaile-repository-package)

### [![](https://camo.githubusercontent.com/121334458fd245d900fab425c019e61008487a789bbaf10b5203260b4f64979b/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f76692f392f39312f46435f42617263656c6f6e615f6c6f676f2e737667)](https://camo.githubusercontent.com/121334458fd245d900fab425c019e61008487a789bbaf10b5203260b4f64979b/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f76692f392f39312f46435f42617263656c6f6e615f6c6f676f2e737667)

[](#)

Overview
--------

[](#overview)

The ThaiLe Repository is used to abstract the data layer, making our application more flexible to maintain

You want to know a little more about the Repository pattern? [Read this great article](http://bit.ly/1IdmRNS).

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Composer](#composer)
    - [Laravel](#laravel)
- [Methods](#methods)
    - [Repository Interface](#repositoryinterface)
- [Usage](#usage)

Installation
------------

[](#installation)

### Composer

[](#composer)

Update the composer.json file:

```
{
    "require": {
        "thaile/repository": "dev-master"
    }
}

```

From the root directory of your project run the command:

```
composer update

```

### Laravel

[](#laravel)

In the config/app.php add `ThaiLe\Repository\Providers\RepositoryServiceProvider::class` to the end of the `provider` array

Publish Configuration

```
php artisan vendor:publish --provider="ThaiLe\Repository\Providers\RepositoryServiceProvider"

```

Methods
-------

[](#methods)

### Repository Interface

[](#repository-interface)

ThaiLe\\Repository\\Contracts\\RepositoryInterface

- all($columns = array('\*'))
- paginate($limit = null, $columns = \['\*'\])
- find($id, $columns = \['\*'\])
- findSoftDelete($id, $columns = \['\*'\])
- findByField($field, $value, $columns = \['\*'\])
- findWhere(array $where, $columns = \['\*'\])
- findWhereIn($field, array $where, $columns = \[\*\])
- findWhereNotIn($field, array $where, $columns = \[\*\])
- create(array $attributes)
- update(array $attributes, $id)
- delete($id)
- with(array $relations)
- applyCriteria()
- pushCriteria()
- popCriteria()
- getCriteria()
- getByCriteria()
- skipCriteria()
- resetCriteria()

Usage
-----

[](#usage)

### In your model

[](#in-your-model)

Create a model with the fillable attributes

```
namespace App;

use Illuminate\Database\Eloquent

class Book extends Eloquent
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'category', 'price',
    ];
}
```

### In your repository

[](#in-your-repository)

Create a repository interface

```
namespace App\Repositories\Contracts;

class BookRepositoryInterface
{

}
```

Create a repository

```
namespace App\Repositories\Eloquents;

use ThaiLe\Repository\Eloquent\BaseRepository;
use App\Book;
use App\Repositories\Contracts\BookRepositoryInterface;

class BookRepository extends BaseRepository implements BookRepositoryInterface
{

    /**
         * Specify Model class name
         *
         * @return string
         */
        function model()
        {
            return Book::class;
        }
}
```

### In the register of the AppServiceProvider or any custom service provider

[](#in-the-register-of-the-appserviceprovider-or-any-custom-service-provider)

```
$this->app->bind(BookRepositoryInterface::class, BookRepository::class);

```

### In your controller

[](#in-your-controller)

```
namespace App\Http\Controllers;

use App\Repositories\Contracts\BookRepositoryInterface;

class BookController extends Controller
{

    /**
     * View the listing books.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(BookRepositoryInterface $bookRepository)
    {
        $bookRepository->all();

        return view('home');
    }
}
```

### Create a Criteria

[](#create-a-criteria)

Criteria is a way to change query logic by specific conditions.

- Create a MyBookCriteriaInterface

```
namespace App\Repositories\Contracts\Criteria;

interface MyBookCriteriaInterface {}
```

- Implements in the MyBooksCriteria

```
namespace App\Repositories\Eloquents\Criteria;

use ThaiLe\Repository\Contracts\CriteriaInterface;
use ThaiLe\Repository\Contracts\RepositoryInterface;
use App\Repositories\Contracts\Criteria\MyBookCriteriaInterface;

class MyBooksCriteria implements CriteriaInterface, MyBookCriteriaInterface
{
    public function apply($model, RepositoryInterface $repository)
        {
            $model = $model->where('user_id','=', Auth::user()->id );
            return $model;
        }
}
```

### In the register of the AppServiceProvider or any custom service provider

[](#in-the-register-of-the-appserviceprovider-or-any-custom-service-provider-1)

```
$this->app->bind(MyBookCriteriaInterface::class, MyBooksCriteria::class);

```

### Using in your controller or whatever logical file

[](#using-in-your-controller-or-whatever-logical-file)

```
namespace App\Http\Controllers;

use App\Repositories\Contracts\BookRepositoryInterface;
use App\Repositories\Contracts\Criteria\MyBookCriteriaInterface;

class BookController extends Controller
{

    /**
     * View the listing books.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(BookRepositoryInterface $bookRepository, MyBookCriteriaInterface $criteria)
    {
        $bookRepository->pushCriteria($criteria);
        $bookRepository->all();

        return view('home');
    }
}
```

### Generators

[](#generators)

Create your repositories (Repository, RepositoryInterface, Model, Migration file) quickly thought the generator

### Configuration

[](#configuration)

All generator configurations are located in the config/repository.php file.

```
'generator'  => [
        'basePath'      => app_path(),
        'rootNamespace' => 'App\\',
        'paths'         => [
            'repositories' => 'Repositories/Eloquents',
            'interfaces'   => 'Repositories/Contracts',
            'models'       => 'Models',
        ]
    ]

```

### Commands

[](#commands)

Using the following command to generate a repository for your Book model

```
php artisan make:repository Book

```

Generating with some fields are fillable

```
php artisan make:repository Book --fillable="string:title,text:content"

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a578447ea9346b2612f7978d196dc3e84ef7322dff373306c5955d61365c72f?d=identicon)[thaile.dev](/maintainers/thaile.dev)

---

Top Contributors

[![thaile0101](https://avatars.githubusercontent.com/u/45391541?v=4)](https://github.com/thaile0101 "thaile0101 (1 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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