Created
March 29, 2014 04:30
-
-
Save gravitano/9848438 to your computer and use it in GitHub Desktop.
Simple repository extended.
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 Smile\Repositories; | |
| use App; | |
| class BaseRepository | |
| { | |
| protected $model; | |
| public function __construct() | |
| { | |
| $this->model = App::make($this->model); | |
| } | |
| } |
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 Smile\Repositories; | |
| class UserRepository extends BaseRepository | |
| { | |
| protected $model = 'User'; | |
| public function all($paginate = 10) | |
| { | |
| return $this->model->paginate($paginate); | |
| } | |
| } |
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 | |
| use Smile\Respository\UserRespository; | |
| class UsersController extends BaseController | |
| { | |
| protected $respository; | |
| public function __construct(UserRespository $respository) | |
| { | |
| $this->respository = $respository; | |
| } | |
| public function index() | |
| { | |
| $users = $this->respository->all(); | |
| return View::make('users.index', compact('data')); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment