Created
February 8, 2014 08:49
-
-
Save coreymcmahon/8878743 to your computer and use it in GitHub Desktop.
A Pattern for Reusable Repository Design in Laravel - http://www.slashnode.com/reusable-repository-design-in-laravel/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Acme\Repositories; | |
use Acme\Abstracts\Repository as AbstractRepository; | |
class UserRepository extends AbstractRepository implements UserRepositoryInterface | |
{ | |
// This is where the "magic" comes from: | |
protected $modelClassName = 'User'; | |
// This class only implements methods specific to the UserRepository | |
public function findByUserName($username) | |
{ | |
$where = call_user_func_array("{$this->modelClassName}::where", array($username)); | |
return $where->get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment