Skip to content

Commit

Permalink
version + repo methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Mar 12, 2015
1 parent 86de738 commit a419aa1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"require": {
"typicms/core": "~1.8.0"
"typicms/core": "~2.0.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/PublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function index()
{
TypiCMS::setModel($this->repository->getModel());

$places = $this->repository->getAll();
$places = $this->repository->all();

return view('places::public.index')
->withPlaces($places);
Expand All @@ -40,7 +40,7 @@ public function index()
public function search()
{

$models = $this->repository->getAll();
$models = $this->repository->all();

return view('places::public.results')
->with(compact('models'));
Expand Down
4 changes: 2 additions & 2 deletions src/Repositories/CacheDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function byPage($page = 1, $limit = 10, array $with = array('translations
* @param array $with Eager load related models
* @return Collection
*/
public function getAll(array $with = array('translations'), $all = false)
public function all(array $with = array('translations'), $all = false)
{
$cacheKey = md5(App::getLocale() . 'all' . $all . implode('.', $with) . implode('.', Input::all()));

if ($this->cache->has($cacheKey)) {
return $this->cache->get($cacheKey);
}

$models = $this->repo->getAll(array('translations'), $all);
$models = $this->repo->all(array('translations'), $all);

// Store in cache for next request
$this->cache->put($cacheKey, $models);
Expand Down
11 changes: 4 additions & 7 deletions src/Repositories/EloquentPlace.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ public function byPage($page = 1, $limit = 10, array $with = array(), $all = fal
->take($limit);

if (! $all) {
// take only translated items that are online
$query->whereHasOnlineTranslation();
$query->online();
}
$query->order();
$models = $query->get();

// Build query to get totalItems
$queryTotal = $this->model;
if (! $all) {
// take only translated items that are online
$queryTotal->whereHasOnlineTranslation();
$queryTotal->online();
}

// Put items and totalItems in stdClass
Expand All @@ -67,7 +65,7 @@ public function byPage($page = 1, $limit = 10, array $with = array(), $all = fal
* @param array $with Eager load related models
* @return Collection Object with $items
*/
public function getAll(array $with = array(), $all = false)
public function all(array $with = array(), $all = false)
{
// get search string
$string = Input::get('string');
Expand All @@ -78,8 +76,7 @@ public function getAll(array $with = array(), $all = false)
->where('locale', App::getLocale());

if (! $all) {
// take only translated items that are online
$query->whereHasOnlineTranslation();
$query->online();
}

$string && $query->where('title', 'LIKE', '%'.$string.'%');
Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/PlaceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ public function byPage($page = 1, $limit = 10, array $with = array('translations
* @param array $with Eager load related models
* @return Collection
*/
public function getAll(array $with = array('translations'), $all = false);
public function all(array $with = array('translations'), $all = false);
}

0 comments on commit a419aa1

Please sign in to comment.