2017 © Pedro Peláez
 

library repository

Reusable Laravel repository interface.

image

caffeinated/repository

Reusable Laravel repository interface.

  • Monday, July 2, 2018
  • by kai_desu
  • Repository
  • 3 Watchers
  • 25 Stars
  • 1,775 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 10 Forks
  • 6 Open issues
  • 20 Versions
  • 13 % Grown

The README.md

This package has been abandoned and is no longer maintained.

Caffeinated Repository

Source License, (*1)

Getting Started

Introduction

The Caffeinated Repository package allows the means to implement a standard boilerplate repository interface. This covers the standard Eloquent methods in a non-static, non-facade driven way right out of the box. Fear not though Batman! The Caffeinated Repository package does not limit you in any way when it comes to customizing (e.g overriding) the provided interface or adding your own methods., (*2)

Installing Caffeinated Repository

It is recommended that you install the package using Composer., (*3)

composer require caffeinated/repository

This package is compliant with PSR-1, PSR-2, and PSR-4. If you find any compliance oversights, please send a patch via pull request., (*4)

Using Repositories

Create a Model

Create your model like you normally would. We'll be wrapping our repository around our model to access and query the database for the information we need., (*5)

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model

class Book extends Model
{
    //
}

Create a Repository

Create a new Repository class - usually these classes are simply stored within a Repositories directory. There are a few requirements for each repository instance:, (*6)

  • Repository classes must extend the Caffeinated EloquentRepository class.
  • Repository classes must specify a public property pointing to the model.
  • Repository classes must specify an array of cache tags. These tags are used by the package to handle automatic cache busting when relevent values change within the database.
<?php

namespace App\Repositories;

use App\Models\Book;
use Caffeinated\Repository\Repositories\EloquentRepository;

class BookRepository extends EloquentRepository
{
    /**
     * @var Model
     */
    public $model = Book::class;

    /**
     * @var array
     */
    public $tag = ['book'];
}

Injecting a Repository

Once you've built and configured your repository instance, you may inject the class within your classes where needed:, (*7)

<?php

namespace App\Http\Controllers;

use App\Repositories\BookRepository;

class BookController extends Controller
{
    /**
     * @var BookRepository
     */
    protected $book;

    /**
     * Create a new BookController instance.
     *
     * @param  BookRepository  $book
     */
    public function __construct(BookRepository $book)
    {
        $this->book = $book;
    }

    /**
     * Display a listing of all books.
     *
     * @return Response
     */
    public function index()
    {
        $books = $this->book->findAll();

        return view('books.index', compact('books'));
    }
}

The Versions

02/07 2018

dev-master

9999999-dev

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

02/07 2018

v3.3

3.3.0.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

26/10 2017

v3.2

3.2.0.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

01/06 2017

v3.1.1

3.1.1.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

27/05 2017

v3.1

3.1.0.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

03/04 2017

v3.0.5

3.0.5.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

10/11 2016

dev-analysis-q204vP

dev-analysis-q204vP

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

31/10 2016

v3.0.4

3.0.4.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

20/10 2016

v3.0.3

3.0.3.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

22/09 2016

v3.0.2

3.0.2.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

20/09 2016

v3.0.1

3.0.1.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

24/08 2016

v3.0

3.0.0.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

28/07 2016

v2.1.2

2.1.2.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

24/06 2016

v2.1.1

2.1.1.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

24/06 2016

v2.1

2.1.0.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

22/06 2016

v2.0

2.0.0.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

26/02 2016

v1.0.3

1.0.3.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

26/02 2016

v1.0.2

1.0.2.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

06/02 2016

v1.0.1

1.0.1.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated

23/12 2015

v1.0

1.0.0.0

Reusable Laravel repository interface.

  Sources   Download

MIT

The Requires

 

by Shea Lewis

laravel repository eloquent caffeinated