Skip to content

Instantly share code, notes, and snippets.

@gravitano
Created March 29, 2014 04:30
Show Gist options
  • Select an option

  • Save gravitano/9848438 to your computer and use it in GitHub Desktop.

Select an option

Save gravitano/9848438 to your computer and use it in GitHub Desktop.
Simple repository extended.
<?php namespace Smile\Repositories;
use App;
class BaseRepository
{
protected $model;
public function __construct()
{
$this->model = App::make($this->model);
}
}
<?php namespace Smile\Repositories;
class UserRepository extends BaseRepository
{
protected $model = 'User';
public function all($paginate = 10)
{
return $this->model->paginate($paginate);
}
}
<?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