File: D:/HostingSpaces/ZelfVerkopen/zelfverkopen.nl/app/KommaApp/Vacancies/VacanciesComposer.php
<?php
namespace App\KommaApp\Vacancies;
use Carbon\Carbon;
use Illuminate\View\View;
class VacanciesComposer
{
static $vacancies;
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
// Only load posts once
if (!static::$vacancies) {
// Load the latest 4 for
static::$vacancies = \App::getSite()
->vacancies()
->with('translation')
->where('active', 1)
->orderBy('lft')
->get();
}
if($view->getName() === 'site.partials.vacanciesButton'){
$amountOfVacancies = static::$vacancies->count();
$view->with('amountOfVacancies', $amountOfVacancies);
}
else{
$view->with('vacancies', static::$vacancies);
}
}
}