Skip to content

Instantly share code, notes, and snippets.

@DevAly
Created December 18, 2018 07:57
Show Gist options
  • Save DevAly/41860e36b472a9a3d1c6d7c4c005a97e to your computer and use it in GitHub Desktop.
Save DevAly/41860e36b472a9a3d1c6d7c4c005a97e to your computer and use it in GitHub Desktop.
not completed yet
<?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