PHPackages                             svensp/laravel-thin-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. [Database &amp; ORM](/categories/database)
4. /
5. svensp/laravel-thin-repository

ActiveLibrary[Database &amp; ORM](/categories/database)

svensp/laravel-thin-repository
==============================

Repository trait to add conditions and forget them on get/find

2.0.0(5y ago)0219MITPHP

Since Aug 27Pushed 5y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (3)Used By (0)

laravel-thin-repository
=======================

[](#laravel-thin-repository)

thin repository tries to make it simple to extend the beatiful chaining of conditions found in the laravel Eloquent querybuilder to a repository for this model.

Updating
--------

[](#updating)

- 1.0.0 -&gt; 2.0.0: the condition and advancedCondition functions no longer take the name as parameter with a default value. They instead return an ElementRenamer which allows to specify a name via the `named` method.
    Example: `$this->condition(function() {})->named('user');`

Install
-------

[](#install)

laravel thin repository is installed via composer

composer install svensp/laravel-thin-repository

Use
---

[](#use)

The core of laravel thi repository is the ThinRepository trait. It will give you the following methods on your repository:

- public find() - findOrFail with the current conditions
- public get() - get with the current conditions
- protected condition(Closure $condition, string $name = null) - set a condition through a lambda function
- protected advancedCondition(Condition $condition, string $name = null) - set a condition through an object implementing the `Condition` interface

Conditions will stack unless given a name. Conditions with the same name will override eachother.

```
