File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/CareersJobs/Kms/CareersJobSection.php
<?php
/**
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\Komma\CareersJobs\Kms;
//The new object oriented attributes
use App\Komma\Dynamic\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\ComponentArea;
use App\Komma\Kms\Core\Attributes\OnOff;
use App\Komma\Kms\Core\Attributes\Select;
use App\Komma\Kms\Core\Attributes\Seperator;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
use App\Komma\Kms\Core\Attributes\Title;
use App\Komma\Kms\Core\Sections\NoLanguageTabsDirector;
use App\Komma\Kms\Core\Sections\Section;
use App\Komma\Kms\Core\Sections\SectionTabGroups;
use App\Komma\Kms\Core\Sections\SectionTabItem;
use App\Komma\Kms\Core\Sections\SectionTabsBuilder;
use App\Komma\Kms\Core\ValidationSet;
use App\Komma\Routes\RouteService;
use App\Komma\Sites\SiteServiceInterface;
use Illuminate\Database\Eloquent\Collection;
class CareersJobSection extends Section
{
protected $slug = 'careersjobs';
/**
* PageSection constructor.
* @param CareersJobService $sectionService
* @param RouteService $routeService
* @param SiteServiceInterface $siteService
*/
// function __construct(Kms $kms, PageRepository $repository)
public function __construct(CareersJobService $sectionService, RouteService $routeService, SiteServiceInterface $siteService)
{
$sectionTabDirector = new NoLanguageTabsDirector(new SectionTabsBuilder()); //Can make tabs for us. also see KmsSection::__construct
parent::__construct($sectionService, $routeService, $siteService, $sectionTabDirector);
}
/**
* Generates the attributes for this section. They all must extend the App\Komma\Kms\Core\Attributes\Attribute class
* This is the place where you need to setup your sections appearance. Just make sure you build an array of attributes
* and put each attribute in a AbstractSectionTabItem with a SectionTabGroups constant to link them to a tab.
*
* @see PageRepository::saveModel()
* @return Collection A collection of SectionTabItems
*/
protected function generateAttributes(): Collection
{
//*****************************************************************************************\\
//*** Define attribute validation sets ***\\
//*****************************************************************************************\\
$requiredValidationSet = (new ValidationSet())
->setRules('required')
->setMessages(['required' => __('validation.required')]);
//*****************************************************************************************\\
//*** Generate the attributes ***\\
//*****************************************************************************************\\
$attributes = [];
$pageOptionModels = $this->sectionService->getOptionsForSelect();
$attributes[] = (new Select())
->setItems($pageOptionModels->toArray())
->setLabelText(__('kms/pages.parent_page'))
->setExcludeCurrentModelItem(true)
->setStyleClass('hidden')
->mapValueFrom(Attribute::ValueFromModel, 'parent_id');
$attributes[] = (new OnOff())
->setLabelText(__('kms/global.active'))
->mapValueFrom(Attribute::ValueFromModel, 'active');
$attributes[] = (new TextField(__('kms/global.name')))
->setPlaceholderText(__('kms/global.enterName'))
->mapValueFrom(Attribute::ValueFromModel, 'name')
->setValidationSet($requiredValidationSet);
$attributes[] = (new TextField(__('kms/careersjobs.career_id')))
->setPlaceholderText(__('kms/careersjobs.enter_career_id'))
->mapValueFrom(Attribute::ValueFromModel, 'careers_id')
->setValidationSet($requiredValidationSet);
$attributes[] = (new TextField(__('kms/careersjobs.tag')))
->setPlaceholderText(__('kms/careersjobs.enter_tag'))
->mapValueFrom(Attribute::ValueFromModel, 'tag');
$attributes[] = (new Seperator());
$attributes[] = (new Title(__('kms/products.seo')));
$attributes[] = (new TextField(__('kms/global.metaTitle')))
->setPlaceholderText(__('kms/global.enterTitle'))
->mapValueFrom(Attribute::ValueFromModel, 'meta_title')
->setContentCounterAmount(60);
$attributes[] = (new TextArea())
->setLabelText(__('kms/global.metaDescription'))
->setPlaceholderText(__('kms/global.enterMetaDescription'))
->mapValueFrom(Attribute::ValueFromModel, 'meta_description')
->setContentCounterAmount(155);
$availableComponentTypes = [
ComponentTypes::CAREERS_JOB_DESCRIPTION,
ComponentTypes::CAREERS_JOB_REQUIREMENTS,
ComponentTypes::HEADING,
ComponentTypes::TEXT_IMAGE,
ComponentTypes::DOUBLE_TEXT,
ComponentTypes::QUOTE,
ComponentTypes::VIDEO,
ComponentTypes::CARDS,
ComponentTypes::TILES,
ComponentTypes::ACCORDION_FIXED_IMAGE,
ComponentTypes::ACCORDION_TEXTAREA,
ComponentTypes::CAPTERRA,
ComponentTypes::IMAGE,
ComponentTypes::TEXT,
ComponentTypes::DATA_SECURITY,
// ComponentTypes::PRODUCT_TABLE,
ComponentTypes::IMAGE_TEXT_STEPS,
ComponentTypes::SEPARATOR,
ComponentTypes::CUSTOMER_STORY_TABS,
ComponentTypes::USP,
ComponentTypes::CUSTOMER_STORY_SLIDER,
// ComponentTypes::CUSTOMER_LOGOS,
ComponentTypes::CUSTOMER_LOGOS_BY_COUNTRY,
ComponentTypes::STORY_SLIDER,
ComponentTypes::CAROUSEL_IMAGES,
ComponentTypes::HEADING_CONTENT,
];
$attributes[] = (new ComponentArea())
// ->disableBackgroundOption()
->setSubFolder('careers_job_data')
->setComponentTypes($availableComponentTypes)
->mapValueFrom(Attribute::ValueFromComponents, 'careers_job_components');
$tabItems = new Collection();
foreach ($attributes as $attribute) {
$tabItems->push(new SectionTabItem($attribute, SectionTabGroups::General));
}
return $tabItems;
}
/**
* This method will stop the load entities of the kmsSiteSection
*
* @return array
*/
public function loadEntities()
{
return [];
}
}