HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/Anvil/anvil-industries.com/app/KommaApp/Vacancies/VacancyService.php
<?php


namespace App\KommaApp\Vacancies;


use App\KommaApp\Pages\Models\Page;
use App\KommaApp\Vacancies\Models\Vacancy;
use Carbon\Carbon;

class VacancyService
{

    private $today;

    public function __construct()
    {
        $this->today = Carbon::now()->addHour();
        $this->today = $this->today->format('Y-m-d H:i:s');
    }

    public function getAllVacancies($pagination = false, $itemsPerPage = 9)
    {

        $site = \App::getSite();

        if($site->slug != 'anvil'){
            $vacancies = $site
                ->vacancies()
                ->where('active', 1)
                ->where('date', '<=', $this->today)
                ->orderBy('date','desc')
                ->orderBy('created_at', 'desc')
                ->with('translation', 'images', 'sites')
                ->has('translation');
        }
        else{
            $vacancies = Vacancy::where('active', 1)
                ->where('date', '<=', $this->today)
                ->orderBy('date','desc')
                ->orderBy('created_at', 'desc')
                ->with('translation', 'images', 'sites')
                ->has('translation');
        }

        if($pagination)
        {
            $vacancies = $vacancies->paginate($itemsPerPage);
        }
        else
        {
            $vacancies = $vacancies->get();
        }
        return $vacancies;
    }


    public function expandBreadCrumbTree(Page &$page, Vacancy $vacancy, $links){

        if(!isset($links->specialisms)) return;

        $tree = $page->breadcrumbTree;

        $tree[] = (object)[
            'name' => $vacancy->translation->name,
            'url' => '/' . $links->vacancies->route . '/'.$vacancy->translation->slug,
            'node' => $vacancy,
        ];

        $page->breadcrumbTree = $tree;
    }


}