File: D:/HostingSpaces/Anvil/anvil-industries.com/app/KommaApp/Vacancies/VacanciesCounterComposer.php
<?php
namespace App\KommaApp\Vacancies;
use App\KommaApp\Vacancies\Models\Vacancy;
use Illuminate\View\View;
class VacanciesCounterComposer
{
static $vacanciesCounter;
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
// Only count the vacancies once
if(!static::$vacanciesCounter){
$site = \App::getSite();
if($site->slug == 'anvil'){
static::$vacanciesCounter = Vacancy::where('active', 1)
->has('translation')
->count();
}
else{
static::$vacanciesCounter = \App::getSite()
->vacancies()
->where('active', 1)
->has('translation')
->count();
}
}
$view->with('vacanciesCounter', static::$vacanciesCounter);
}
}