File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Komma/Solutions/SolutionService.php
<?php
namespace App\Komma\Solutions;
use App\Komma\Base\Service;
use Carbon\Carbon;
class SolutionService 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 appendSolutionsToLinks(&$links)
{
// If the products page isn't found, return
if (! isset($links->solutions)) {
return;
}
// Find all pages
if (! $solutions = $this->site
->solutions()
->where('lft', '!=', 1)
->orderBy('lft', 'asc')
->has('translations')
->has('solutionGroup')
->with('translations', 'solutionGroup', 'solutionGroup.translation')
->get()
) {
return;
}
$this->appendModelsToLinks($links, $solutions, 'solution', $links->solutions, true);
}
public function getAllSolutions($pagination = false, $itemsPerPage = 9)
{
$solutions = $this->site
->solutions()
->with('translation')
->where('lft', '!=', 1)
->orderBy('lft', 'desc')
// We need to use a join to select the active solution because that is defined on the translations
->join('solution_translations', 'solutions.id', '=', 'solution_translations.solution_id')
->select('solutions.*', 'solution_translations.active', 'solution_translations.language_id')
->where('active', 1)
->where('language_id', \App::getLanguage()->id);
if ($pagination) {
$solutions = $solutions->paginate($itemsPerPage);
} else {
$solutions = $solutions->get();
}
return $solutions;
}
}