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/SBogers10/koen-cox-groendesign.komma.pro/database/seeds/VacancySeeder.php
<?php

use App\Vacancies\Models\Vacancy;
use App\Vacancies\Models\VacancyTranslation;
use Komma\KMS\Globalization\Languages\Models\Language;

use Illuminate\Database\Seeder;
use Illuminate\Support\Collection;

class VacancySeeder extends Seeder
{
    /**
     * Run the seed
     */
    public function run()
    {
        //Get the languages
        $languages = Language::whereIn('iso_2', ['nl', 'en', 'de'])->get(['id', 'iso_2']);

        //Create the root page
        $siteRootVacancy = new Vacancy(['active' => 0]);
        $siteRootVacancy->makeRoot();

        $chefVacancy = $this->createChefVacancy($siteRootVacancy, $languages);
    }

    /**
     * @param Vacancy $siteRootVacancy
     * @param Collection $languages
     * @return Vacancy
     */
    private function createChefVacancy(Vacancy $siteRootVacancy, Collection $languages): Vacancy
    {
        //Create the service itself...
        $vacancy = new Vacancy([
            'active'      => 1,
        ]);

        $vacancy->makeLastChildOf($siteRootVacancy);
        $vacancy->save();

        //...the Dutch translation
        $language = $languages->where('id', '104')->first();
        $vacancyTranslation = new VacancyTranslation([
            'slug'                => 'chef-kok',
            'name'                => 'Chef kok gezocht',
            'hero_active'         => 1,
            'hero_title'          => 'Chef kok gezocht voor het bakken van hamburgers',
            'hero_description'    => 'Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Proin faucibus arcu quis ante.. Aenean massa. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Aliquam lobortis. Vestibulum facilisis, purus nec pulvinar iaculis, ligula mi congue nunc, vitae euismod ligula urna in dolor. Phasellus nec sem in justo pellentesque facilisis.',
        ]);
        $vacancyTranslation->language()->associate($language);
        $vacancyTranslation->translatable()->associate($vacancy);
        $vacancyTranslation->save();

        return $vacancy;
    }

}