File: D:/HostingSpaces/SBogers10/conmeq.komma.pro/database/seeds/DefaultSitePageComponentSeeder.php
<?php
use App\Komma\Components\Component\ComponentSaveState;
use App\Komma\Components\ComponentArea\ComponentAreaSaveState;
use App\Komma\Components\ComponentArea\ComponentAreaService;
use App\Komma\Components\ComponentType\ComponentTypes;
use App\Komma\Globalization\Languages\Models\Language;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\ComponentArea;
use App\Komma\Pages\Models\Page;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Request;
class DefaultSitePageComponentSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
* @throws ReflectionException
* @throws Throwable
*/
public function run()
{
/** @var ComponentAreaService $componentAreaService */
$componentAreaService = app(ComponentAreaService::class);
//Get the languages
$languages = Language::whereIn('iso_2', ['nl', 'en', 'de'])->get(['id', 'iso_2']);
//Get the page component areas
$componentAreaAttributesByIso2 = [];
foreach($languages as $language) {
$componentAreaAttributesByIso2[$language->iso_2] = $this->getComponentAreaForLanguage($languages->where('iso_2', $language->iso_2)->first());
}
//Create the components by delegating to specialized methods
$this->createHomePageComponents(Page::where('code_name', '=', 'home')->first(), $componentAreaAttributesByIso2, $componentAreaService);
$this->createAboutUsPageComponents(Page::where('code_name', '=', 'about')->first(), $componentAreaAttributesByIso2, $componentAreaService);
$this->createWorkflowPageComponents(Page::where('code_name', '=', 'workflow')->first(), $componentAreaAttributesByIso2, $componentAreaService);
$this->createReferencesPageComponents(Page::where('code_name', '=', 'references')->first(), $componentAreaAttributesByIso2, $componentAreaService);
$this->createPrivacyPageComponents(Page::where('code_name', '=', 'privacy')->first(), $componentAreaAttributesByIso2, $componentAreaService);
$this->createDisclaimerPageComponents(Page::where('code_name', '=', 'disclaimer')->first(), $componentAreaAttributesByIso2, $componentAreaService);
}
/**
* @param Page $page
* @param array $componentAreaAttributesByIso2
* @param ComponentAreaService $componentAreaService
* @throws ReflectionException
* @throws Throwable
*/
private function createHomePageComponents(Page $page, array $componentAreaAttributesByIso2, ComponentAreaService $componentAreaService)
{
//Create component save states
$componentSaveStates = [];
$componentSaveStates[] = (new ComponentSaveState())
->setId(0)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::CONTENT_PERSONAL)
->setData([
"ComponentArea|dynamic_group_sections|C0|content_header|nl" => "Intro heading",
"ComponentArea|dynamic_group_sections|C0|content_text|nl" => "<p>Algemene introductie van het bedrijf. Bacon ipsum dolor amet landjaeger kevin cow rump sirloin flank leberkas jowl shank short ribs prosciutto venison shankle. Sirloin bresaola pancetta, capicola porchetta sausage ball tip shoulder. Pork chop andouille turkey filet mignon. Fatback boudin prosciutto, hamburger swine jowl beef ribs chicken t-bone landjaeger frankfurter alcatra. </p>",
"ComponentArea|dynamic_group_sections|C0|personal_header|nl" => "Callout van maximaal 2 a 3 regels. Neem vrijblijvend contact op.",
"ComponentArea|dynamic_group_sections|C0|servicepoints|nl" => "2",
"ComponentArea|dynamic_group_sections|C0|buttons|nl" => "6"
])
->setSortOrder(0);
$componentSaveStates[] = (new ComponentSaveState())
->setId(-1)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::USP)
->setData([
"ComponentArea|dynamic_group_sections|C-1|header|nl" => "5 redenen om <br>voor ons te kiezen",
"ComponentArea|dynamic_group_sections|C-1|USP1|nl" => "Bacon ipsum dolor amet landjaeger kevin cow rump",
"ComponentArea|dynamic_group_sections|C-1|USP2|nl" => "Sirloin flank leberkas jowl shank short ribs ",
"ComponentArea|dynamic_group_sections|C-1|USP3|nl" => "Sirloin bresaola pancetta, capicola porchetta ",
"ComponentArea|dynamic_group_sections|C-1|USP4|nl" => " Fatback boudin prosciutto, hamburger swine jowl",
"ComponentArea|dynamic_group_sections|C-1|USP5|nl" => "Beef ribs chicken t-bone landjaeger frankfurter alcatra",
"ComponentArea|dynamic_group_sections|C-1|USP6|nl" => "",
"ComponentArea|dynamic_group_sections|C-1|USP7|nl" => "",
"ComponentArea|dynamic_group_sections|C-1|buttons|nl" => "1",
"ComponentArea|dynamic_group_sections|C-1|image|nl" => "[]"
])->setSortOrder(1);
//Create component area savestate, and put the component save states in ot
$componentAreaSaveState = new ComponentAreaSaveState();
foreach($componentSaveStates as $componentSaveState) $componentAreaSaveState->addComponentSaveState($componentSaveState);
//Convert the savestate to json and give it to the component area attribute
$saveStateJson = json_encode($componentAreaSaveState);
$componentAreaAttributesByIso2['nl']->setValue($saveStateJson);
Request::merge(['ComponentArea|dynamic_group_sections|C-1|image|nl' => '[]']); //Needed to fake a file input that the documentServices uses internally via the componentAreaService. Else it won't process the whole component area.
//Let the componentAreaService save it
$componentAreaService->saveOrUpdateComponentAreaForAttribute($page, $componentAreaAttributesByIso2['nl']);
}
/**
* @param Page $page
* @param array $componentAreaAttributesByIso2
* @param ComponentAreaService $componentAreaService
* @throws ReflectionException
* @throws Throwable
*/
private function createAboutUsPageComponents(Page $page, array $componentAreaAttributesByIso2, ComponentAreaService $componentAreaService)
{
$componentSaveStates[] = (new ComponentSaveState())
->setId(0)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::TEXT_IMAGE)
->setData([
"ComponentArea|dynamic_group_sections|C0|text|nl" => "<h2>Passie met een grote P </h2>\n<p>Introductie van de persoon achter het bedrijf. Flank spare ribs pork chop landjaeger pig sirloin chuck, ground round biltong. Kevin tail beef ribs pork chop chicken venison frankfurter. Cupim beef ribs leberkas, ham tenderloin burgdoggen picanha landjaeger ball tip flank corned beef pastrami turducken t-bone shankle. </p>\n<p>Heb je nog vragen? Dr. Butcher helpt je graag. Neem vrijblijvend <a href=\"/contact\">contact</a> op. </p>",
"ComponentArea|dynamic_group_sections|C0|buttons|nl" => "2",
"ComponentArea|dynamic_group_sections|C0|image|nl" => "[]",
"ComponentArea|dynamic_group_sections|C0|caption|nl" => "",
"ComponentArea|dynamic_group_sections|C0|reversed|nl" => "0"
])->setSortOrder(0);
//Create component area savestate, and put the component save states in ot
$componentAreaSaveState = new ComponentAreaSaveState();
foreach($componentSaveStates as $componentSaveState) $componentAreaSaveState->addComponentSaveState($componentSaveState);
//Convert the savestate to json and give it to the component area attribute
$saveStateJson = json_encode($componentAreaSaveState);
$componentAreaAttributesByIso2['nl']->setValue($saveStateJson);
Request::merge(['ComponentArea|dynamic_group_sections|C0|image|nl' => '[]']); //Needed to fake a file input that the documentServices uses internally via the componentAreaService. Else it won't process the whole component area.
//Let the componentAreaService save it
$componentAreaService->saveOrUpdateComponentAreaForAttribute($page, $componentAreaAttributesByIso2['nl']);
}
/**
* @param Page $page
* @param array $componentAreaAttributesByIso2
* @param ComponentAreaService $componentAreaService
* @throws ReflectionException
* @throws Throwable
*/
private function createWorkflowPageComponents(Page $page, array $componentAreaAttributesByIso2, ComponentAreaService $componentAreaService)
{
$componentSaveStates[] = (new ComponentSaveState())
->setId(0)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::CONTENT_SLIDER)
->setData([
"ComponentArea|dynamic_group_sections|C0|label_1|nl" => "1. Peppers",
"ComponentArea|dynamic_group_sections|C0|header_1|nl" => "Spicy jalapeno bacon ipsum",
"ComponentArea|dynamic_group_sections|C0|text_1|nl" => "<p>Spicy jalapeno bacon ipsum dolor amet bacon pancetta turkey buffalo pastrami pork belly sausage. Meatloaf ham hock picanha fatback buffalo shank frankfurter pancetta kielbasa. Short loin ham shankle pancetta jerky frankfurter</p>\n<ol>\n<li>Spicy jalapeno bacon ipsum dolor amet bacon</li>\n<li>Pancetta turkey buffalo pastrami pork belly sausage.</li>\n<li>Meatloaf ham hock picanha fatback buffalo shank</li>\n<li>Frankfurter pancetta kielbasa. Short loin ham shankle pancetta jerky frankfurter</li>\n</ol>",
"ComponentArea|dynamic_group_sections|C0|buttons_1|nl" => "",
"ComponentArea|dynamic_group_sections|C0|image_1|nl" => "[]",
"ComponentArea|dynamic_group_sections|C0|reversed_1|nl" => "0",
"ComponentArea|dynamic_group_sections|C0|label_2|nl" => "2. Pulled Pork",
"ComponentArea|dynamic_group_sections|C0|header_2|nl" => "Pulled Pork",
"ComponentArea|dynamic_group_sections|C0|text_2|nl" => "<p>Pork belly ribeye hamburger turkey ham hock tongue spare ribs shank porchetta venison andouille tenderloin drumstick meatball. Andouille hamburger rump jerky tenderloin kevin beef ribs porchetta t-bone.</p>\n<ol>\n<li>Sirloin picanha burgdoggen</li>\n<li>Leberkas corned beef beef</li>\n<li>Ribs strip steak jowl biltong.</li>\n</ol>",
"ComponentArea|dynamic_group_sections|C0|buttons_2|nl" => "",
"ComponentArea|dynamic_group_sections|C0|image_2|nl" => "[]",
"ComponentArea|dynamic_group_sections|C0|reversed_2|nl" => "0",
"ComponentArea|dynamic_group_sections|C0|label_3|nl" => "3. Bacon",
"ComponentArea|dynamic_group_sections|C0|header_3|nl" => "In bacon we trust",
"ComponentArea|dynamic_group_sections|C0|text_3|nl" => "<p>Burgdoggen ham hock shoulder meatball short loin picanha tongue brisket pork chop chuck.</p>\n<ol>\n<li>Pork loin swine pastrami, frankfurter tri-tip bacon ham prosciutto filet mignon.</li>\n<li>Ball tip pork belly cow drumstick, picanha turkey pig shank biltong andouille porchetta brisket sirloin hamburger.</li>\n<li>Buffalo meatloaf tri-tip bacon kielbasa.</li>\n</ol>",
"ComponentArea|dynamic_group_sections|C0|buttons_3|nl" => "",
"ComponentArea|dynamic_group_sections|C0|image_3|nl" => "[]",
"ComponentArea|dynamic_group_sections|C0|reversed_3|nl" => "0",
"ComponentArea|dynamic_group_sections|C0|label_4|nl" => "4. Chicken burgdoggen",
"ComponentArea|dynamic_group_sections|C0|header_4|nl" => "Chicken burgdoggen tail bacon picanha",
"ComponentArea|dynamic_group_sections|C0|text_4|nl" => "<p>Chicken burgdoggen tail bacon picanha frankfurter.</p>\n<ol>\n<li>Hamburger landjaeger jerky</li>\n<li>Ball tip burgdoggen t-bone capicola strip steak short ribs beef ribs beef ham shankle buffalo doner. </li>\n<li>Prosciutto kielbasa salami tenderloin.</li>\n</ol>",
"ComponentArea|dynamic_group_sections|C0|buttons_4|nl" => "2",
"ComponentArea|dynamic_group_sections|C0|image_4|nl" => "[]",
"ComponentArea|dynamic_group_sections|C0|reversed_4|nl" => "0"
])->setSortOrder(0);
$componentSaveStates[] = (new ComponentSaveState())
->setId(-1)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId('10')
->setData([
"ComponentArea|dynamic_group_sections|C-1|text|nl" => "Quote over hoe het de samenwerking met het bedrijf bevalt. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ac lorem tempus ante euismod bibendum eu vitae eros. Aliquam blandit a sem vel ullamcorper. Mauris nec lacus ut enim venenatis porttitor. Duis scelerisque arcu eu posuere sodales. Curabitur ac neque in sem sodales imperdiet. Maecenas tincidunt augue nec fringilla tempus. ",
"ComponentArea|dynamic_group_sections|C-1|title|nl" => "Henk Ingrids",
"ComponentArea|dynamic_group_sections|C-1|subtitle|nl" => "C.E.O. @ Somecompany",
"ComponentArea|dynamic_group_sections|C-1|image|nl" => "[]"
])->setSortOrder(1);
//Create component area savestate, and put the component save states in ot
$componentAreaSaveState = new ComponentAreaSaveState();
foreach($componentSaveStates as $componentSaveState) $componentAreaSaveState->addComponentSaveState($componentSaveState);
//Convert the savestate to json and give it to the component area attribute
$saveStateJson = json_encode($componentAreaSaveState);
$componentAreaAttributesByIso2['nl']->setValue($saveStateJson);
Request::merge(['ComponentArea|dynamic_group_sections|C0|image_1|nl' => '[]']); //Needed to fake a file input that the documentServices uses internally via the componentAreaService. Else it won't process the whole component area.
Request::merge(['ComponentArea|dynamic_group_sections|C0|image_2|nl' => '[]']); //Needed to fake a file input that the documentServices uses internally via the componentAreaService. Else it won't process the whole component area.
Request::merge(['ComponentArea|dynamic_group_sections|C0|image_3|nl' => '[]']); //Needed to fake a file input that the documentServices uses internally via the componentAreaService. Else it won't process the whole component area.
Request::merge(['ComponentArea|dynamic_group_sections|C0|image_4|nl' => '[]']); //Needed to fake a file input that the documentServices uses internally via the componentAreaService. Else it won't process the whole component area.
Request::merge(['ComponentArea|dynamic_group_sections|C-1|image|nl' => '[]']); //Needed to fake a file input that the documentServices uses internally via the componentAreaService. Else it won't process the whole component area.
//Let the componentAreaService save it
$componentAreaService->saveOrUpdateComponentAreaForAttribute($page, $componentAreaAttributesByIso2['nl']);
}
/**
* @param Page $page
* @param array $componentAreaAttributesByIso2
* @param ComponentAreaService $componentAreaService
* @throws ReflectionException
* @throws Throwable
*/
private function createReferencesPageComponents(Page $page, array $componentAreaAttributesByIso2, ComponentAreaService $componentAreaService)
{
$componentSaveStates[] = (new ComponentSaveState())
->setId(0)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::TEXT)
->setData([
"ComponentArea|dynamic_group_sections|C0|text|nl" => "<p>Sed aliquam ultrices mauris. Quisque malesuada placerat nisl. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Fusce neque.</p>\n<h3>Referenties</h3>\n<p>Nam eget dui. Etiam ut purus mattis mauris sodales aliquam. Phasellus accumsan cursus velit. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum.</p>\n<p>Vestibulum rutrum, mi nec elementum vehicula, eros quam gravida nisl, id fringilla neque ante vel mi. Sed aliquam ultrices mauris. Aenean ut eros et nisl sagittis vestibulum. Praesent nonummy mi in odio.</p>"
])->setSortOrder(0);
//Create component area savestate, and put the component save states in ot
$componentAreaSaveState = new ComponentAreaSaveState();
foreach($componentSaveStates as $componentSaveState) $componentAreaSaveState->addComponentSaveState($componentSaveState);
//Convert the savestate to json and give it to the component area attribute
$saveStateJson = json_encode($componentAreaSaveState);
$componentAreaAttributesByIso2['nl']->setValue($saveStateJson);
//Let the componentAreaService save it
$componentAreaService->saveOrUpdateComponentAreaForAttribute($page, $componentAreaAttributesByIso2['nl']);
}
/**
* @param Page $page
* @param array $componentAreaAttributesByIso2
* @param ComponentAreaService $componentAreaService
* @throws ReflectionException
* @throws Throwable
*/
private function createPrivacyPageComponents(Page $page, array $componentAreaAttributesByIso2, ComponentAreaService $componentAreaService)
{
$componentSaveStates[] = (new ComponentSaveState())
->setId(0)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::TEXT)
->setData([
"ComponentArea|dynamic_group_sections|C0|text|nl" => "<h2>Verwerken persoonsgegevens</h2>\n<p>Wij verwerken persoonsgegevens indien deze zijn ingevuld op onze website of wanneer je contact met ons opneemt met interesse in onze dienstverlening. Wij vragen om bedrijfsnaam, naam, e-mailadres, telefoonnummer en eventueel een bericht, zodat wij gerichte (klanten)service kunnen bieden.</p>\n<h3>Cookies</h3>\n<p>Op onze website maken we gebruik van verschillende cookies. Cookies zijn kleine stukjes informatie die gedurende een bezoek aan een website worden opgeslagen op je computer. Cookies van barbecutie.nl zijn veilig voor je pc, laptop, telefoon of tablet.</p>\n<h3>Functionele cookies</h3>\n<p>Deze cookies zorgen dat de website op een correcte manier functioneert.</p>\n<h4>Analytische cookies</h4>\n<p>Door middel van deze cookies wordt inzicht verkregen in het gebruik van de website. De privacy van bezoekers blijft met deze analytische cookies gewaarborgd. Met behulp van de verkregen data kan de website worden geoptimaliseerd, waardoor de gebruikerservaring kan worden verbeterd. Barbecutie maakt hierbij gebruik van cookies ten behoeve van Google Analytics en Google Tag Manager.</p>\n<p>Cookies kunnen via de browserinstellingen verwijderd of uitgeschakeld worden. Het kan voorkomen dat de website dan niet meer optimaal kan worden gebruikt.</p>"
])->setSortOrder(0);
//Create component area savestate, and put the component save states in ot
$componentAreaSaveState = new ComponentAreaSaveState();
foreach($componentSaveStates as $componentSaveState) $componentAreaSaveState->addComponentSaveState($componentSaveState);
//Convert the savestate to json and give it to the component area attribute
$saveStateJson = json_encode($componentAreaSaveState);
$componentAreaAttributesByIso2['nl']->setValue($saveStateJson);
//Let the componentAreaService save it
$componentAreaService->saveOrUpdateComponentAreaForAttribute($page, $componentAreaAttributesByIso2['nl']);
}
/**
* @param Page $page
* @param array $componentAreaAttributesByIso2
* @param ComponentAreaService $componentAreaService
* @throws ReflectionException
* @throws Throwable
*/
private function createDisclaimerPageComponents(Page $page, array $componentAreaAttributesByIso2, ComponentAreaService $componentAreaService)
{
$componentSaveStates[] = (new ComponentSaveState())
->setId(0)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::TEXT)
->setData([
"ComponentArea|dynamic_group_sections|C0|text|nl" => "<h2>Elektronische communicatie</h2>\n<p>U kunt ons, nu en in de toekomst, op verschillende manieren bereiken. Onder meer via de website en e-mail. Deze vormen van elektronische communicatie zijn nooit 100% veilig. Door gevoelige of vertrouwelijke informatie zonder ‘versleuteling’ via het open internet aan ons te versturen aanvaardt u het risico, dat deze informatie bij derden terechtkomt.</p>\n<h3>Informatie; hyperlinks</h3>\n<p>Wij bieden, tenzij uitdrukkelijk anders wordt vermeld, de informatie op de website aan als een vorm van dienstverlening. In het bijzonder aan onze huidige en toekomstige relaties, maar in feite aan een ieder die toegang heeft tot internet. Er kunnen geen rechten aan worden ontleend. Wij betrachten altijd de grootst mogelijke zorgvuldigheid bij het samenstellen en/of opmaken van onze websites. Dit betekent evenwel niet, dat wij kunnen garanderen dat de op de website verstrekte informatie altijd juist, up-to-date of compleet is.<br />In de gevallen, dat op de website hyperlinks worden aangeboden betekent dit niet, dat wij de via die links eventueel aangeboden diensten of producten aanbevelen. Ook voor de juistheid van de informatie op die websites kunnen wij niet instaan.</p>\n<h3>Aansprakelijkheid</h3>\n<p>Komma en/of onze werknemers zijn niet aansprakelijk voor enigerlei schade die ontstaat als gevolg van (onzorgvuldig of onjuist) gebruik van de informatie of mogelijkheden die de website biedt of gebruik van de website zelf, tenzij er sprake is van opzet of bewuste roekeloosheid. Gebruik van de website geschiedt dan ook volledig voor uw eigen risico. Ook zijn wij niet aansprakelijk in de gevallen dat de website (tijdelijk) niet bereikbaar is.</p>\n<h3>Wijzigingen</h3>\n<p>Wij zullen de informatie op de website periodiek aanvullen en eventueel wijzigen. Dit kunnen wij steeds onmiddellijk en zonder enige kennisgeving vooraf doen.</p>\n<h3>Rechten van intellectuele eigendom</h3>\n<p>Ten aanzien van alle informatie en/of andere auteursechtelijk beschermde werken op de websites behouden wij uitdrukkelijk onze auteursrechten en die van onze licentiegevers voor. Voor gebruik van het hiervoor bedoelde heeft u voorafgaande toestemming van ons nodig. U kunt uw verzoeken in dit verband aan ons richten per e-mail.</p>\n<h3>Toepasselijk recht</h3>\n<p>Op de websites en deze disclaimer is Nederlands recht van toepassing. Alle eventuele uit hoofde van de websites en de disclaimer voortvloeiende geschillen zullen bij uitsluiting worden voorgelegd aan de bevoegde rechter in Nederland.</p>"
])->setSortOrder(0);
$componentSaveStates[] = (new ComponentSaveState())
->setId(-1)
->setVersion(ComponentAreaService::SAVE_VERSION)
->setComponentTypeId(ComponentTypes::IMAGE)
->setData([
"ComponentArea|dynamic_group_sections|C57|image|nl" => "[]",
"ComponentArea|dynamic_group_sections|C57|caption|nl" => ""
])->setSortOrder(1);
//Create component area savestate, and put the component save states in ot
$componentAreaSaveState = new ComponentAreaSaveState();
foreach($componentSaveStates as $componentSaveState) $componentAreaSaveState->addComponentSaveState($componentSaveState);
//Convert the savestate to json and give it to the component area attribute
$saveStateJson = json_encode($componentAreaSaveState);
$componentAreaAttributesByIso2['nl']->setValue($saveStateJson);
//Let the componentAreaService save it
$componentAreaService->saveOrUpdateComponentAreaForAttribute($page, $componentAreaAttributesByIso2['nl']);
}
/**
* @param Language $language
* @return Attribute|ComponentArea
*/
private function getComponentAreaForLanguage(Language $language)
{
return (new ComponentArea())
->setComponentTypes([
ComponentTypes::TEXT,
ComponentTypes::IMAGE,
ComponentTypes::TEXT_IMAGE,
ComponentTypes::VIDEO,
ComponentTypes::USP,
ComponentTypes::QUOTE,
ComponentTypes::CONTENT_PERSONAL,
ComponentTypes::CONTENT_SLIDER,
])
->setSubFolder('dynamic_group_sections')
->mapValueFrom(Attribute::ValueFromComponentArea, 'dynamic_group_sections')
->setAssociatedLanguage($language);
}
}