Skip to content

Commit

Permalink
Cleaning pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
bestmomo committed Dec 8, 2014
1 parent cfd9a1f commit 90f5c98
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 51 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(UserGestion $user_gestion)
$this->user_gestion = $user_gestion;
}

/**
/**
* Show the admin panel.
*
* @Get("admin", as="admin")
Expand Down
25 changes: 12 additions & 13 deletions app/Http/Controllers/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Http\Requests\SearchRequest;
use Illuminate\Contracts\Auth\Guard;
use App\Gestion\UserGestion;
use App\Services\Pagination;
use App\Services\Medias;

/**
Expand All @@ -22,27 +21,27 @@ class BlogController extends Controller {
*/
protected $blog_gestion;

/**
* The UserGestion instance.
*
* @var App\Gestion\UserGestion
*/
protected $user_gestion;
/**
* The UserGestion instance.
*
* @var App\Gestion\UserGestion
*/
protected $user_gestion;

/**
/**
* The pagination number.
*
* @var App\Gestion\UserGestion
* @var int
*/
protected $nbrPages;

/**
* Create a new BlogController instance.
*
* @param App\Gestion\BlogGestion $blog_gestion
* @param App\Gestion\UserGestion $user_gestion
* @param App\Gestion\UserGestion $user_gestion
* @return void
*/
*/
public function __construct(
BlogGestion $blog_gestion,
UserGestion $user_gestion)
Expand Down Expand Up @@ -77,7 +76,7 @@ public function index(
{
$statut = $this->user_gestion->getStatut();
$posts = $this->blog_gestion->index(10, $statut == 'admin' ? null : $auth->user()->id);
$links = Pagination::makeLengthAware($posts, $this->blog_gestion->count($statut == 'admin' ? null : $auth->user()->id), 10);
$links = str_replace('/?', '?', $posts->render());
return view('back.blog.index', compact('posts', 'links'));
}

Expand All @@ -95,7 +94,7 @@ public function indexOrder(
{
$statut = $this->user_gestion->getStatut();
$posts = $this->blog_gestion->index(10, $statut == 'admin' ? null : $auth->user()->id, $request->get('name'), $request->get('sens'));
$links = Pagination::makeLengthAware($posts, $this->blog_gestion->count($statut == 'admin' ? null : $auth->user()->id), 10);
$links = str_replace('/?', '?', $posts->render());
return response()->json([
'view' => view('back.blog.table', compact('statut', 'posts'))->render(),
'links' => $links
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Gestion\CommentGestion;
use App\Gestion\UserGestion;
use App\Gestion\BlogGestion;
use App\Services\Pagination;

/**
* @Resource("comment", except={"create","show"})
Expand Down Expand Up @@ -41,7 +40,7 @@ public function __construct(
public function index()
{
$comments = $this->comment_gestion->index(4);
$links = Pagination::makeLengthAware($comments, $this->comment_gestion->count(), 4);
$links = str_replace('/?', '?', $comments->render());
return view('back.commentaires.index', compact('comments', 'links'));
}

Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Http\Requests\UserUpdateRequest;
use App\Http\Requests\RoleRequest;
use Illuminate\Http\Request;
use App\Services\Pagination;

/**
* @Resource("user")
Expand Down Expand Up @@ -82,7 +81,7 @@ private function indexGo($role, $ajax = false)
];
$counts['total'] = array_sum($counts);
$users = $this->user_gestion->index(4, $role);
$links = Pagination::makeLengthAware($users, $counts[$role], 4);
$links = str_replace('/?', '?', $users->render());
$roles = $this->role_gestion->all();
if($ajax)
{
Expand Down
33 changes: 0 additions & 33 deletions app/Services/Pagination.php

This file was deleted.

0 comments on commit 90f5c98

Please sign in to comment.