File: D:/HostingSpaces/SBogers10/hem-mechatronics.komma.pro/app/Komma/Products/ProductService.php
<?php
namespace App\Komma\Products;
use App\Komma\Base\Service;
use Carbon\Carbon;
class ProductService 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 getAllProducts($pagination = false, $itemsPerPage = 9)
{
$products = $this->site
->products()
->with('translation', 'images')
->where('active', 1)
->orderBy('lft')
->whereHas('translation');
if($pagination)
{
$products = $products->paginate($itemsPerPage);
}
else
{
$products = $products->get();
}
return $products;
}
}