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/shop.komma.nl/app/Discounts/DiscountSection.php
<?php


namespace App\Discounts;

use Komma\KMS\Core\Attributes\DatePicker;
use Komma\KMS\Core\Attributes\Select;
use Komma\KMS\Core\Attributes\TextArea;
use Komma\KMS\Core\Attributes\OnOff;
use Komma\KMS\Core\Attributes\TextField;
use Komma\KMS\Core\Attributes\Title;
use Illuminate\Database\Eloquent\Model;
use Komma\KMS\Core\Attributes\View;
use Komma\KMS\Core\Sections\Section;

class DiscountSection extends Section
{
    protected string $slug = "discounts";

    /**
     * Define the attributes and tabs for this section.
     *
     * @param Model $currentModel
     */
    public function defineAttributesAndTabs(Model $currentModel = null): void
    {
        //*****************************************************************************************\\
        //*** Generate the attributes                                                           ***\\
        //*****************************************************************************************\\
        $attributes = [];

        //Build the general attributes and put them in the attributes array
        $attributes[] = (new Title())
            ->setLabelText(__('KMS::discounts.discount'));

        $attributes[] = (new OnOff())
            ->setLabelText(__('KMS::global.active'))
            ->switchOn()
            ->setReference( 'active');

        $attributes[] = (new Select())
            ->setLabelText(__('KMS::discounts.type'))
            ->setReference( 'type');

        $attributes[] = (new TextField())
            ->setLabelText(__('KMS::discounts.condition_settings'))
            ->setExplanation(__('KMS::discounts.condition_settings_explanations'))
            ->setReference( 'condition_settings');

        $attributes[] = (new TextField())
            ->setLabelText(__('KMS::discounts.action_settings'))
            ->setExplanation(__('KMS::discounts.action_settings_explanations'))
            ->setReference( 'action_settings');

        $attributes[] = (new DatePicker())
            ->setLabelText(__('KMS::discounts.valid_from'))
            ->setAnimation(DatePicker::ANIMATION_SLIDEDOWN)
            ->setChangeYearAndMonth(true)
            ->setLanguage(DatePicker::LANGUAGE_DUTCH)
            ->setReference( 'valid_from');

        $attributes[] = (new DatePicker())
            ->setLabelText(__('KMS::discounts.valid_trough'))
            ->setAnimation(DatePicker::ANIMATION_SLIDEDOWN)
            ->setChangeYearAndMonth(true)
            ->setLanguage(DatePicker::LANGUAGE_DUTCH)
            ->setReference( 'valid_trough');

        $attributes[] = (new View())
            ->setViewName('shop.partials.discounts.editor')
            ->setViewData([]);

        $this->tabs->makeTab()->addItems($attributes);



        //Build an array with attributes for each current site language
        $this->tabs->makeLanguageTabTemplate()->addItems([
            (new Title())
            ->setLabelText(__('KMS::global.information')),

            (new TextField())
                ->setLabelText(__('KMS::global.title'))
                ->setPlaceholderText(__('KMS::global.enterTitle'))
                ->setReference( 'title'),

            (new TextArea())
                ->setLabelText(__('KMS::global.description'))
                ->setReference( 'description'),
        ]);
    }
}