2017 © Pedro Peláez
 

library laravel-repositories

A Laravel package for the Repository Design Pattern.

image

nalingia/laravel-repositories

A Laravel package for the Repository Design Pattern.

  • Wednesday, March 14, 2018
  • by nalingia
  • Repository
  • 1 Watchers
  • 1 Stars
  • 387 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 85 % Grown

The README.md

A Laravel package for the Repository design pattern

Latest Version on Packagist Build Status Software License Total Downloads, (*1)

Repositories is a simple package to simplify the creation of scaffolding code when using the Repository Design Pattern. It adds an artisan command which creates the repository and the related contract., (*2)

Installation

You can install the package via composer:, (*3)

composer require nalingia/laravel-repositories

Then you have to add the related Service Provider to the providers configuration array in config/app.php:, (*4)

'providers' => [
  ...
  Nalingia\Repositories\RepositoriesServiceProvider::class,
  ...
]

Usage

The package provides an additional artisan command called make:repository which accepts as only parameter the model's class name., (*5)

For instance, if you need to create a repository of users you can type:, (*6)

php artisan make:repository User

The command will create both the repository and the related contract in app/Repositories and app/Repositories/Contracts folders, respectively. Default folders and namespaces can be changed, (*7)

Available API

The generated repositories will inherit from Nalingia\Repositories\AbstractEloquentRepository which provides a bunch of useful and general purpose methods: * Get all models:, (*8)

public function all(array $with = []); 
  • Get model having the given id:
public function findById($id, array $with = [], $fail = true);
  • Get the first model having $key attribute equals to $value:
public function getFirstBy($key, $value, array $with = [], $comparator = '=', $fail = false);
  • Get all models having $key attribute equals to $value:
public function getManyBy($key, $value, array $with = [], $comparator = '=');
  • Get first model matching $where clauses:
public function getFirstWhere(array $where, $with = [], $fail = false);
  • Get all models matching $where clauses:
public function getAllWhere($where, $with = [], $columns = ['*']);
  • Get paginated models:
public function getByPage($page = 1, $limit = 10, array $with = []);
  • Create a new model:
public function create(array $data);
  • Update a model:
public function update($model, array $data);
  • Delete a model:
public function delete($model);
  • Truncate the table related to the model:
public function truncate();
  • Get all models having column_name in $needles:
public function getAllWhereColumnNameIn(array $needles, array $with = []);

You can contribute to the common methods by proposing a pull request., (*9)

Settings

If you need to change the default command settings, you can publish the repositories.php configuration file using the command:, (*10)

php artisan vendor:publish --provider="Nalingia\Repositories\RepositoriesServiceProvider"

Change log

Please, see CHANGELOG for more information about what has changed recently., (*11)

Contributing

Please see CONTRIBUTING for details., (*12)

Testing

You can run the tests with:, (*13)

composer test

or, (*14)

vendor/bin/phpunit

License

The MIT License (MIT). Please see License File for more information., (*15)

The Versions

14/03 2018

dev-develop

dev-develop

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

14/03 2018

dev-master

9999999-dev

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

14/03 2018

1.3.4

1.3.4.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

14/03 2018

1.3.3

1.3.3.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

14/03 2018

1.3.2

1.3.2.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

14/03 2018

1.3.1

1.3.1.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

13/03 2018

1.3

1.3.0.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

13/03 2018

dev-feature/tests

dev-feature/tests

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

09/03 2018

1.2.0

1.2.0.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

13/02 2018

1.1.1

1.1.1.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

31/01 2018

1.1.0

1.1.0.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

09/01 2018

1.0.1

1.0.1.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern

09/01 2018

1.0.0

1.0.0.0

A Laravel package for the Repository Design Pattern.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gianmarco Nalin

orm model repositories design pattern