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/SBogers95/rentman.io/app/Komma/Dynamic/ComponentType/Types/IndustryCards.php
<?php

namespace App\Komma\Dynamic\ComponentType\Types;

use App\Komma\Dynamic\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\OnOff;
use App\Komma\Kms\Core\Attributes\Select;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
use App\Komma\Solutions\SolutionService;

class IndustryCards extends AbstractComponentType
{
    protected $id = ComponentTypes::INDUSTRY_CARDS;
    protected $name = 'industry-cards';

    public function  __construct()
    {
        parent::__construct();

        $solutionService = new SolutionService();
        $solutions = $solutionService->getAllSolutions();

        $solutions->each(function ($solution, $i) {

            $this->attributes->push((new TextField($solution->translation->name))
                ->setReadOnly(true)
                ->setDataAttribute('tab', ($i + 1))
            );

            $this->attributes->push((new TextField('Card title'))
                ->mapValueFrom(Attribute::ValueFromItself, 'title_' . ($i + 1))
                ->setValue($solution->translation->name)
                ->setDataAttribute('tab', ($i + 1))
            );

            $this->attributes->push((new TextField('Card link url'))
                ->mapValueFrom(Attribute::ValueFromItself, 'link_' . ($i + 1))
                ->setValue('/en/solutions/' . $solution->translation->slug)
                ->setDataAttribute('tab', ($i + 1))
            );

            $this->attributes->push((new TextArea())
                ->setLabelText('Card description')
                ->mapValueFrom(Attribute::ValueFromItself, 'description_' . ($i + 1))
                ->setValue($solution->translation->description)
                ->setDataAttribute('tab', ($i + 1))
            );

            $this->attributes->push((new OnOff())
                ->setLabelText("Active")
                ->setStyleClass('is-active')
                ->mapValueFrom(Attribute::ValueFromItself, 'active_' . ($i + 1))
                ->setDataAttribute('tab', ($i + 1))
            );

            $this->attributes->push((new Select())
                ->setItems($this->getIconOptions())
                ->setLabelText('Icon')
                ->mapValueFrom(Attribute::ValueFromItself, 'icon_' . ($i + 1))
                ->setDataAttribute('tab', ($i + 1))
            );

        });


        }

}