patinthehat / laravel-repositories
Laravel 5 Repository classes
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
pkg:composer/patinthehat/laravel-repositories
Requires
- php: >=5.6.4
This package is not auto-updated.
Last update: 2025-10-26 06:51:56 UTC
README
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.