-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from douglas-88/dev
Class Pagination
- Loading branch information
Showing
6 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
|
||
class User extends Model | ||
{ | ||
protected $table = "user"; | ||
protected $table = "users"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
|
||
namespace App\traits; | ||
|
||
|
||
trait Links | ||
{ | ||
protected $maxLinks; | ||
|
||
private function previous(){ | ||
if($this->page > 1){ | ||
|
||
} | ||
} | ||
|
||
private function next(){ | ||
|
||
} | ||
|
||
public function links(){ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
|
||
namespace Core; | ||
|
||
|
||
class Paginate | ||
{ | ||
private $page; | ||
private $perPage; | ||
private $offSet; | ||
private $pages; | ||
private $registers; | ||
|
||
private function current(){ | ||
$this->page = filter_input(INPUT_GET,"page",FILTER_SANITIZE_NUMBER_INT) ?? 1; | ||
} | ||
|
||
private function perPage($perPage){ | ||
$this->perPage = $perPage ?? 30; | ||
} | ||
|
||
private function offSet(){ | ||
$this->offSet = ($this->page * $this->perPage) - $this->perPage; | ||
} | ||
|
||
private function pages(){ | ||
$this->pages = ceil($this->registers/$this->perPage); | ||
} | ||
|
||
public function getRegisters($registers){ | ||
$this->registers = $registers; | ||
} | ||
|
||
public function sqlPaginate(){ | ||
return " LIMIT {$this->perPage} OFFSET {$this->offSet} "; | ||
} | ||
|
||
public function paginate($perPage){ | ||
$this->current(); | ||
$this->perPage($perPage); | ||
$this->offSet(); | ||
$this->pages(); | ||
} | ||
} |