patinthehat/laravel-repositories

Laravel 5 Repository classes
12 1
Install
composer require patinthehat/laravel-repositories
Latest Version:v1.0.1
PHP:>=5.6.4
License:MIT
Last Updated:Apr 1, 2017
Links: GitHub  ·  Packagist
Maintainer: patinthehat

Laravel Repositories


This package provides a basic Repository pattern implementation for use with Laravel 5+.

Installation


This package may be installed with composer:

composer require patinthehat/laravel-repositories

Usage


Extend the Repository class and define its model method to create a repository for that model:

use Permafrost\Repository;

class UserRepository extends Repository
{
    public static function model()
    {
        return 'App\\User';
    }
}

The repository can then be used:

  $user = UserRepository::findByFirstName('john');

Dynamic Find Methods


The Repository class allows for dynamic findByN/findAllByN method calls, which will search the repository model's field N for its first argument. For example,

    UserRepository::findByFirstName('john')

results in a call to

    User::where('first_name', 'john')->first()

License


This package is open source software, available under the MIT license. See LICENSE for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

404,034,618 608
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

384,821,166 4,658