diff --git a/app/Controller/UserController.php b/app/Controller/UserController.php
index fcb808c..b36c317 100755
--- a/app/Controller/UserController.php
+++ b/app/Controller/UserController.php
@@ -29,7 +29,8 @@ public function index(){
$this->view("home",
[
"users" => $this->users->select()->paginate(2)->get(),
- "title" => "Listando Usuários"
+ "title" => "Listando Usuários",
+ "links" => $this->users->links()
]
);
diff --git a/app/Model/User.php b/app/Model/User.php
index 5084dc1..e0ff83b 100755
--- a/app/Model/User.php
+++ b/app/Model/User.php
@@ -6,5 +6,5 @@
class User extends Model
{
- protected $table = "users";
+ protected $table = "user";
}
\ No newline at end of file
diff --git a/app/traits/Links.php b/app/traits/Links.php
index 54b38b0..cabfcc6 100644
--- a/app/traits/Links.php
+++ b/app/traits/Links.php
@@ -6,19 +6,68 @@
trait Links
{
- protected $maxLinks;
+ protected $maxLinks = 4;
private function previous(){
+
if($this->page > 1){
-
+
+ $previous = $this->page - 1;
+
+ $links = "
[1]";
+ $links .= "
+
+ «
+ Previous
+
+ ";
+
+ return $links;
}
+
}
private function next(){
+ if($this->page < $this->pages){
+
+ $next = $this->page + 1;
+
+ $links = "
+
+ »
+ Next
+
+ ";
+ $links .= "pages}\">[{$this->pages}]";
+
+ return $links;
+ }
+
}
- public function links(){
+ public function links()
+ {
+ if($this->page > 0){
+
+ $links = "";
+
+ return $links;
+ }
}
}
\ No newline at end of file
diff --git a/app/traits/Read.php b/app/traits/Read.php
index 4a7653f..1e77473 100644
--- a/app/traits/Read.php
+++ b/app/traits/Read.php
@@ -9,7 +9,7 @@
trait Read
{
- use Links;
+
/**
* Método responsável por
* @param string $fields
@@ -103,4 +103,8 @@ public function paginate($perPage){
return $this;
}
+
+ public function links(){
+ return $this->paginate->links();
+ }
}
\ No newline at end of file
diff --git a/src/Paginate.php b/src/Paginate.php
index 6a3d569..15064f5 100644
--- a/src/Paginate.php
+++ b/src/Paginate.php
@@ -4,6 +4,8 @@
namespace Core;
+use App\traits\Links;
+
class Paginate
{
private $page;
@@ -12,6 +14,8 @@ class Paginate
private $pages;
private $registers;
+ use Links;
+
private function current(){
$this->page = filter_input(INPUT_GET,"page",FILTER_SANITIZE_NUMBER_INT) ?? 1;
}
diff --git a/views/home.html b/views/home.html
index e5ce84a..0b87123 100755
--- a/views/home.html
+++ b/views/home.html
@@ -31,6 +31,7 @@ Usuários
{% endfor %}
+ {{ links | raw }}
{% endblock %}
\ No newline at end of file