File: D:/HostingSpaces/SBogers10/kemi.komma.pro/app/KommaApp/Posts/PostService.php
<?php
namespace App\KommaApp\Posts;
use App\KommaApp\Posts\Models\Post;
use Carbon\Carbon;
class PostService
{
public function getAllPosts($pagination = false, $itemsPerPage = 9)
{
$posts = Post::where('active', '1')
->with('translation', 'images')
->has('translation')
->orderBy('date', 'desc')
->orderBy('created_at', 'desc');
if($pagination)
{
$posts = $posts->paginate($itemsPerPage);
}
else
{
$posts = $posts->get();
}
return $posts;
}
}