shekarsiri / baserepo
Base repositories
1.2
2015-11-27 10:22 UTC
Requires
- php: >=5.5.9
- illuminate/support: ^5.1
This package is not auto-updated.
Last update: 2024-12-07 19:44:20 UTC
README
Example
Repository
use ShekarSiri\BaseRepo\Crudable;
use ShekarSiri\BaseRepo\Pagination;
use ShekarSiri\BaseRepo\Repo;
/**
* Interface LocationRepository
*
*/
interface LocationRepository extends Crudable, Repo, Pagination
{
}
Implementation
use Location;
use ShekarSiri\BaseRepo\CrudableTrait;
use ShekarSiri\BaseRepo\PaginationTrait;
use ShekarSiri\BaseRepo\RepoTrait;
/**
* Class LocationRepositoryEloquent
*
*/
class LocationRepositoryEloquent implements LocationRepository
{
use CrudableTrait, PaginationTrait, RepoTrait;
private $queries = [
'name' => 'LIKE'
];
function __construct(Location $model)
{
$this->model = $model;
}
}
use LocationRepository;
use Illuminate\Http\Request;
class LocationController extends Controller
{
/**
* @var LocationRepository
*/
private $repo;
function __construct(LocationRepository $repo)
{
$this->middleware('auth', ['except' => ['autoComplete']]);
$this->repo = $repo;
}
public function index(Request $request)
{
$locations = $this->repo->pagination(10, [], $request->all());
return response()->json($locations, 200);
}
}