New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

pieterdev/repoflow

A simple trait to allow fluently querying repositories with an eloquent model. Gives back the flexibility of eloquent to some extent, while remaining explicit on which methods are supported by a repository.
23 1
Install
composer require pieterdev/repoflow
Latest Version:1.0.5
PHP:>=5.4.0
Older releases:4
License:MIT
Last Updated:Aug 28, 2014
Links: GitHub  ·  Packagist
Maintainer: pieterdev

repoflow

A simple trait to allow fluently querying repositories with an eloquent model. Gives back the flexibility of eloquent to some extent, while remaining explicit on which methods are supported by a repository.

Using it

Simply:

  1. Add the Pieterdev\Repoflow\FluentRepositoryTrait to your repository class.
  2. Add a protected static $filters= [...] array to your repository class denoting which properties on your model should be filterable.
  3. Have the model your repository is using as a field called $model on your repository class, or have $model be a string containing the name of the eloquent model used by the repository.
  4. You can then do chain queries on your repository, for example `$repo->whereName('Jack')->whereScore(3)->all();
  5. The method all() invokes the query.
<?php

class SomeEloquentRepository implements ISomeRepository {

    use Pieterdev\Repoflow\FluentRepositoryTrait;

    protected static $filters = [
        'name',
        'score'
    ];

    protected $model;

    function __construct(User $userModel) 
    {
        $this->model = $userModel;
    }
}

Related Packages

pawelmysior/laravel-publishable

Toggle the published state of your Eloquent models easily

19,442 22
koodoo/laravel-trait-uuid

A Laravel Eloquent Model trait for adding a UUID to Eloquent Models

16,752 0
koodoo/laravel-trait-updatedby

A Laravel Eloquent Model trait for adding User Id's to Eloquent Models

16,642 1
foothing/laravel-repository

This package provides an implementation of the repository pattern for Laravel 5.

2,307 4
giordanolima/eloquent-repository

Repository pattern for Eloquent ORM with a powerfull cache for database queries.

1,576 29

Version History

Version Released PHP Laravel License
1.0.5 >=5.4.0 MIT
1.0.4 >=5.4.0 MIT
1.0.3 >=5.4.0 MIT
1.0.2 >=5.4.0 4.2.* MIT
1.0.1 >=5.4.0 4.2.*