2017 © Pedro Peláez
 

library laravel-base-repository

A flexible Laravel repository pattern foundation for working with Eloquent ORM

image

kyle-noland/laravel-base-repository

A flexible Laravel repository pattern foundation for working with Eloquent ORM

  • Friday, February 20, 2015
  • by KyleNoland
  • Repository
  • 2 Watchers
  • 7 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

laravel-base-repository

A flexible Laravel repository pattern foundation for working with Eloquent ORM., (*1)

The goal of this package is to provide a foundation for building Laravel Eloquent repositories while still allowing you to create basic queries on the fly., (*2)

Installation

Install this package through Compposer. Edit your project's composer.json file to require kyle-noland/laravel-base-repository, (*3)

``` json "require": { "kyle-noland/laravel-base-repository": "dev-master" }, (*4)


Update Composer from the Terminal

composer update, (*5)


Add the Service Provider to your app/config/app.php file ``` php 'KyleNoland\LaravelBaseRepository\LaravelBaseRepositoryServiceProvider'

Usage

Extend the BaseRepository class and implement your own custom repository logic:, (*6)

``` php <?php namespace MyProject\Repositories;, (*7)

use KyleNoland\LaravelBaseRepository\BaseRepository; use MyProject\Interfaces\CompanyRepositoryInterface; use MyProject\Models\Company;, (*8)

class CompanyRepository extends BaseRepository implements CompanyRepositoryInterface {, (*9)

public function __construct(Company $model)
{
    $this->model = $model;
}

// Add your repository methods here

}, (*10)


The BaseRepository class provides basic COUNT, SELECT, INSERT, UPDATE, DELETE, WHERE, WHERE IN clauses and the ability to eager load related models. ### Counting All Models ``` php $count = $this->companyRepo->count();

Counting a Subset of Models

``` php $count = $this->companyRepo->where('is_active', true)->count();, (*11)


### Selecting Models ``` php $allCompanies = $this->companyRepo->all(); $activeCompanies = $this->companyRepo->where('is_active', true)->get(); $activeCopmaniesInTexas = $this->companyRepo->where('is_active', true)->where('state', 'TX')->get();

The Versions

20/02 2015

dev-master

9999999-dev

A flexible Laravel repository pattern foundation for working with Eloquent ORM

  Sources   Download

The Requires

 

by Kyle Noland