Created
December 18, 2018 07:57
-
-
Save DevAly/41860e36b472a9a3d1c6d7c4c005a97e to your computer and use it in GitHub Desktop.
not completed yet
This file contains hidden or 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
<?php | |
class Post { | |
public function latestWithCategory($amount = 10, $category_id, $pageId, $all = null) { | |
$lastpageNumber = round(intval($all) / intval($amount),PHP_ROUND_HALF_DOWN); | |
$result = $this->model->whereStatus(Status::PUBLISHED)->where('category_id', $category_id)->offset(intval($this->calculateOffset($pageId)))->limit($amount)->orderBy('created_at', 'desc')->get(); | |
if(intval($lastpageNumber) == $pageId){ | |
$stillPosts = false; | |
}else{ | |
$stillPosts = true; | |
} | |
return ['result' => $result,'stillPosts' => $stillPosts]; | |
} | |
public function calculateOffset($pageId) { | |
if (!empty($pageId)) { | |
return $pageId * 7; | |
} | |
return 1; | |
} | |
} | |
class public { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment