All Projects → caffeinated → repository

caffeinated / repository

Licence: MIT license
🏭 Reusable repository interface

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to repository

standardnotes-extensions
Standard Notes Extensions
Stars: ✭ 16 (-44.83%)
Mutual labels:  repository
Banana
🍌 The collection of CRUD helpers for Dapper.
Stars: ✭ 61 (+110.34%)
Mutual labels:  repository
python-resources-for-earth-sciences
A Curated List of Python Resources for Earth Sciences
Stars: ✭ 159 (+448.28%)
Mutual labels:  repository
repository
[PHP 7] Implementation and definition of a base Repository in Domain land.
Stars: ✭ 26 (-10.34%)
Mutual labels:  repository
wikirepo
Python based Wikidata framework for easy dataframe extraction
Stars: ✭ 33 (+13.79%)
Mutual labels:  repository
Dapper.AmbientContext
Ambient context implementation for Dapper.NET
Stars: ✭ 31 (+6.9%)
Mutual labels:  repository
mrgit
A tool for managing projects build using multiple repositories.
Stars: ✭ 42 (+44.83%)
Mutual labels:  repository
readmesfix
Because I'm tired of running into broken READMEs!
Stars: ✭ 63 (+117.24%)
Mutual labels:  repository
backup-repository
Backup storage for E2E GPG-encrypted files, with multi-user, quotas, versioning, using a object storage (S3/Min.io/GCS etc.) and deployed on Kubernetes or standalone.
Stars: ✭ 21 (-27.59%)
Mutual labels:  repository
Pursuit-Core-Android
Pursuit Core Android
Stars: ✭ 45 (+55.17%)
Mutual labels:  repository
ioBroker.heatingcontrol
heating control incl. simple actor handling
Stars: ✭ 43 (+48.28%)
Mutual labels:  repository
langx-java
Java tools, helper, common utilities. A replacement of guava, apache-commons, hutool
Stars: ✭ 50 (+72.41%)
Mutual labels:  repository
aurblobs
Automatically create binary repositories from AUR packages
Stars: ✭ 14 (-51.72%)
Mutual labels:  repository
debianopt-repo
Additional debian repository for awesome open-source projects.
Stars: ✭ 47 (+62.07%)
Mutual labels:  repository
argo
The administrative discovery interface for Stanford's Digital Object Registry
Stars: ✭ 19 (-34.48%)
Mutual labels:  repository
support
A Laravel 5 package which promotes the use of best practices and design patterns
Stars: ✭ 19 (-34.48%)
Mutual labels:  repository
automate-branch-rules-cli
The tool lets you automate the addition, removal or alteration of the branch protection rules for 1 or more branches & repositories in one go.
Stars: ✭ 29 (+0%)
Mutual labels:  repository
TableStorage.Abstractions.POCO
Builds on top of TableStorage.Abstractions (a repository wrapper over Azure Table Storage) such that objects to be serialized to and from Azure Table Storage are Plain Old CLR Objects (POCO) rather than TableEntities.
Stars: ✭ 20 (-31.03%)
Mutual labels:  repository
SlackBuilds
Slackware current slackbuilds (to build my repository)
Stars: ✭ 50 (+72.41%)
Mutual labels:  repository
loopback-next
LoopBack makes it easy to build modern API applications that require complex integrations.
Stars: ✭ 4,412 (+15113.79%)
Mutual labels:  repository

This package has been abandoned and is no longer maintained.

Caffeinated Repository

Source License

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.

Installing Caffeinated Repository

It is recommended that you install the package using Composer.

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.

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.

<?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:

  • 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:

<?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'));
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].