File: D:/HostingSpaces/Neopoints/momsecurity.be/app/Komma/Posts/PostService.php
<?php
namespace App\Komma\Posts;
use App\Komma\Base\Service;
use Carbon\Carbon;
class PostService extends Service
{
private $today;
public function __construct()
{
$this->today = Carbon::now()->addHour();
$this->today = $this->today->format('Y-m-d H:i:s');
parent::__construct();
}
public function getAllPosts($pagination = false, $itemsPerPage = 9)
{
$posts = $this->site
->posts()
->with('translation', 'images')
->where('active', 1)
->where('date', '<=', $this->today)
->orderBy('date','desc')
->orderBy('created_at', 'desc');
if($pagination)
{
$posts = $posts->paginate($itemsPerPage);
}
else
{
$posts = $posts->get();
}
return $posts;
}
}