File: D:/HostingSpaces/SBogers10/stafa.komma.pro/app/Komma/Projects/ProjectService.php
<?php
namespace App\Komma\Projects;
use App\Komma\Base\Service;
use Carbon\Carbon;
class ProjectService 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 getAllProjects($pagination = false, $itemsPerPage = 9)
{
$projects = $this->site
->projects()
->with('translation', 'images')
->where('active', 1)
->orderBy('lft')
->whereHas('translation');
if($pagination)
{
$projects = $projects->paginate($itemsPerPage);
}
else
{
$projects = $projects->get();
}
return $projects;
}
public function getProjectsForHome()
{
$projectsForHome = $this->site
->projects()
->with('translation', 'images')
->where('active', 1)
->orderBy('lft')
->whereHas('translation')
->take(3);
return $projectsForHome;
}
public function getFeaturedProjects()
{
$featuredProjects = $this->site
->projects()
->with('translation', 'images')
->where('active', 1)
->orderBy('featured', 'desc')
->whereHas('translation')
->take(3);
return $featuredProjects;
}
}