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/farmfun.komma.pro/app/Komma/CalendarNotes/Kms/CalendarNoteSection.php
<?php
/**
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma
 */

namespace App\Komma\CalendarNotes\Kms;

//The new object oriented attributes
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\DatePicker;
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\Sections\Section;
use App\Komma\Kms\Core\Sections\Tabs\Collections\NoLanguageTabs;
use App\Komma\Kms\Core\ValidationSet;
use App\Komma\Locations\Kms\LocationService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;

final class CalendarNoteSection extends Section
{
    /**
     * PageSection constructor.
     * @param $slug
     */
//    function __construct(Kms $kms, PageRepository $repository)
    public function __construct($slug)
    {
        $tabs = new NoLanguageTabs();
        parent::__construct($tabs, $slug);
    }

    /**
     * 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()
     * @param Model $currentModel
     * @return Collection A collection of SectionTabItems
     */
    protected function generateAttributes(Model $currentModel = null): Collection
    {
//        \Log::info("PageSection::Generating attributes");

        //*****************************************************************************************\\
        //*** Generate the attributes                                                           ***\\
        //*****************************************************************************************\\
        $attributes = [];

        $requiredValidationSet = (new ValidationSet())
            ->setRules('required')
            ->setMessages(['required' => __('validation.required')]);

        $attributes[] = (new TextField('Naam'))
            ->setValidationSet($requiredValidationSet)
            ->setExplanation('Deze wordt gebruikt in de kalender weergave')
            ->mapValueFrom(Attribute::ValueFromModel, 'name');

        $attributes[] = (new TextArea())
            ->setLabelText('Opmerking')
            ->setPlaceholderText('Vul hier je opmerking in')
            ->mapValueFrom(Attribute::ValueFromModel, 'note');

        $attributes[] = (new Seperator());

        /** @var LocationService $locationService */
        $locationService = app(LocationService::class);
        $attributes[] = (new Select())
            ->setLabelText(__('kms/locationproducts.location'))
            ->setItems($locationService->getOptionsForSelect()->toArray())
            ->setValue(\Input::get('location', 1))
            ->mapValueFrom(Attribute::ValueFromModel, 'location_id');

//        $attributes[] = (new DatePicker(__('kms/reservations.date')))
//            ->setTimeEnabled(false)
        ////            ->disableDateBeforeToday()
//            ->mapValueFrom(Attribute::ValueFromItself, 'date');

        $attributes[] = (new DatePicker(__('kms/calendarnotes.start_date')))
            ->mapValueFrom(Attribute::ValueFromModel, 'start_date');

        $attributes[] = (new DatePicker(__('kms/calendarnotes.end_date')))
            ->mapValueFrom(Attribute::ValueFromModel, 'end_date');

        $attributes[] = (new OnOff())
            ->setLabelText(__('kms/calendarnotes.all_day'))
            ->setExplanation('Wanneer actief zal de gekozen tijd van de start datum naar 00:00 gezet worden en de eind datum naar 23:59.')
            ->mapValueFrom(Attribute::ValueFromModel, 'all_day');

        //Return all attributes as a collection
        return collect($attributes);
    }
}